Documentation ¶
Index ¶
Constants ¶
const Email = 16
const FailEmail = 128
const FailEmpty = 32
const FailLenMax = 4
const FailLenMin = 2
values for invalid field flags
const FailRegexp = 64
const FailValMax = 16
const FailValMin = 8
const FailZero = 256
const Required = 8
const VERSION = "0.3.0"
const ValMaxNotNil = 4
const ValMinNotNil = 2
values used with flags
Variables ¶
This section is empty.
Functions ¶
func Validate ¶
func Validate(obj interface{}, options *ValidationOptions) (bool, map[string]int)
Validate validates fields of a struct. Currently only fields which are string or int (any) are validated. Func returns boolean value that determines whether value is true or false, and a map of fields that failed validation. See Fail* constants for the values.
Types ¶
type FieldValidation ¶
type FieldValidation struct {
// contains filtered or unexported fields
}
type ValidationOptions ¶
type ValidationOptions struct { RestrictFields map[string]bool OverwriteFieldTags map[string]map[string]string OverwriteTagName string ValidateWhenSuffix bool OverwriteFieldValues map[string]interface{} }
Optional configuration for validation: * RestrictFields defines what struct fields should be validated * OverwriteFieldTags can be used to overwrite tags for specific fields * OverwriteTagName sets tag used to define validation (default is "validation") * ValidateWhenSuffix will validate certain fields based on their name, eg. "PrimaryEmail" field will need to be a valid email * OverwriteFieldValues is to use overwrite values for fields, so these values are validated not the ones in struct