Documentation
¶
Index ¶
Constants ¶
View Source
const ( FailLenMin = 2 << iota FailLenMax FailValMin FailValMax FailRegExp FailEmail FailReq FailType )
Variables ¶
This section is empty.
Functions ¶
func Validate ¶
func Validate(obj interface{}, options *ValidateOptions) (bool, map[string]int, error)
Validate takes a struct and validates values of its fields based on their tags.
func ValidateField ¶
func ValidateField(structField reflect.StructField, fieldValue reflect.Value, tagName string) (bool, int)
ValidateField takes a reflected struct field, its value and a tagname and validates the values against the requirements in the tag.
Types ¶
type ValidateOptions ¶
type ValidateOptions struct {
RestrictFields map[string]bool
TagName string
OverwriteValues map[string]interface{}
}
ValidateOptions is an optional configuration for validation: * RestrictFields defines what struct fields should be validated * TagName sets tag used to define validation (default is "validation") * OverwriteValues allows overriding values of fields
Click to show internal directories.
Click to hide internal directories.