Documentation ¶
Index ¶
- Constants
- type Errors
- func (v *Errors) Add(key string, msg string)
- func (v *Errors) Append(ers *Errors)
- func (v *Errors) Count() int
- func (v *Errors) Error() string
- func (v *Errors) Get(key string) []string
- func (v *Errors) HasAny() bool
- func (v *Errors) Keys() []string
- func (e Errors) MarshalXML(enc *xml.Encoder, start xml.StartElement) error
- func (v *Errors) String() string
- type Validator
Constants ¶
const Version = "v0.0.1"
Version of validate
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Errors ¶
type Errors struct { Errors map[string][]string `json:"errors" xml:"errors"` Lock *sync.RWMutex `json:"-"` }
Errors holds onto all of the error messages that get generated during the validation process.
func NewErrors ¶
func NewErrors() *Errors
NewErrors returns a pointer to a Errors object that has been primed and ready to go.
func Validate ¶
Validate takes in n number of Validator objects and will run them and return back a point to a Errors object that will contain any errors.
func (*Errors) Add ¶
Add will add a new message to the list of errors using the given key. If the key already exists the message will be appended to the array of the existing messages.
func (*Errors) Append ¶
Append concatenates two Errors objects together. This will modify the first object in place.
func (*Errors) HasAny ¶
HasAny returns true/false depending on whether any errors have been tracked.
func (Errors) MarshalXML ¶
type Validator ¶
type Validator interface {
IsValid(errors *Errors)
}
Validator must be implemented in order to pass the validator object into the Validate function.
func ValidatorFunc ¶
ValidatorFunc wraps any function in a "Validator" to make it easy to write custom ones.