Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // DisallowUpper is a validator that disallows uppercase characters. DisallowUpper = &CustomValidator{ Key: "disallow_upper", Func: func(fl validator.FieldLevel) bool { for _, r := range fl.Field().String() { if unicode.IsUpper(r) { return false } } return true }, } // DisallowSpace is a validator that disallows spaces. DisallowSpace = &CustomValidator{ Key: "disallow_space", Func: func(fl validator.FieldLevel) bool { for _, r := range fl.Field().String() { if unicode.IsSpace(r) { return false } } return true }, } )
View Source
var URN = &CustomValidator{ Key: "urn", Func: func(fl validator.FieldLevel) bool { fl.Param() u, err := urn.FindURNTypeFromString(fl.Param()) if err != nil { return false } return strings.Contains(fl.Field().String(), u.String()) }, }
URN is a validator that checks if a string is a valid URN (Uniform Resource Name).
Functions ¶
Types ¶
type CustomValidator ¶
type CustomValidator struct { Key string Func validator.Func }
Click to show internal directories.
Click to hide internal directories.