Documentation ¶
Overview ¶
Package validator provides convenient utilities for validation.
Index ¶
- func Validate(v interface{}) error
- func ValidateExcept(v interface{}, fields ...string) error
- func ValidatePartial(v interface{}, fields ...string) error
- func Var(field interface{}, tag string) error
- type Validator
- func (validator *Validator) Register(tag string, fn validate.Func, callValidationEvenIfNull bool) error
- func (validator *Validator) Validate(v interface{}) error
- func (validator *Validator) ValidateExcept(v interface{}, fields ...string) error
- func (validator *Validator) ValidatePartial(v interface{}, fields ...string) error
- func (validator *Validator) Var(field interface{}, tag string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Validate ¶
func Validate(v interface{}) error
Validate a struct exposed fields base on the definition of validate tag.
func ValidateExcept ¶ added in v0.2.0
ValidateExcept validates all the fields except the given fields.
func ValidatePartial ¶ added in v0.2.0
ValidatePartial validates the fields passed in only, ignoring all others.
Types ¶
type Validator ¶ added in v0.1.9
type Validator struct {
// contains filtered or unexported fields
}
Validator is a validation helper.
func Get ¶ added in v0.2.0
Get get the tag validator from cache or create new one if not exists. If tag is empty, return Root() validator.
func Root ¶ added in v0.1.9
func Root() *Validator
Root return root validator instance using default 'validate' tag.
func (*Validator) Register ¶ added in v0.1.9
func (validator *Validator) Register(tag string, fn validate.Func, callValidationEvenIfNull bool) error
Register adds a validation with the given tag
func (*Validator) Validate ¶ added in v0.1.9
Validate a struct exposed fields base on the definition of validate tag.
func (*Validator) ValidateExcept ¶ added in v0.1.9
ValidateExcept validates all the fields except the given fields.
func (*Validator) ValidatePartial ¶ added in v0.1.9
ValidatePartial validates the fields passed in only, ignoring all others.