validate: Index | Files | Directories

package validate

import ""


Package Files


type Errors Uses

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 Uses

func NewErrors() *Errors

NewErrors returns a pointer to a Errors object that has been primed and ready to go.

func Validate Uses

func Validate(validators ...Validator) *Errors

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 Uses

func (v *Errors) Add(key string, msg string)

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 Uses

func (v *Errors) Append(ers *Errors)

Append concatenates two Errors objects together. This will modify the first object in place.

func (*Errors) Count Uses

func (v *Errors) Count() int

Count returns the number of errors.

func (*Errors) Error Uses

func (v *Errors) Error() string

Error implements the error interface

func (*Errors) Get Uses

func (v *Errors) Get(key string) []string

Get returns an array of error messages for the given key.

func (*Errors) HasAny Uses

func (v *Errors) HasAny() bool

HasAny returns true/false depending on whether any errors have been tracked.

func (*Errors) Keys Uses

func (v *Errors) Keys() []string

Keys return all field names which have error

func (Errors) MarshalXML Uses

func (e Errors) MarshalXML(enc *xml.Encoder, start xml.StartElement) error

func (*Errors) String Uses

func (v *Errors) String() string

type Validator Uses

type Validator interface {
    IsValid(errors *Errors)

Validator must be implemented in order to pass the validator object into the Validate function.

func ValidatorFunc Uses

func ValidatorFunc(fn func(errors *Errors)) Validator

ValidatorFunc wraps any function in a "Validator" to make it easy to write custom ones.



Package validate imports 4 packages (graph) and is imported by 65 packages. Updated 2020-04-06. Refresh now. Tools for package owners.