Documentation ¶
Overview ¶
Package rules 一些通用的验证规则
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Required = web.NewRuleFunc(locales.Required, func(a any) bool { if a == nil { return false } return !reflect.ValueOf(a).IsZero() }) Strength = web.NewRule(locales.StrengthInvalid, validator.Strength(8, 1, 0, 1)) // Avatar 头像验证规则,可以为空或是 URL Avatar = web.NewRule(locales.InvalidValue, validator.OrFunc(validator.URL, func(a any) bool { if a == nil { return true } switch v := a.(type) { case string: return v == "" case []byte: return len(v) == 0 case []rune: return len(v) == 0 default: return false } })) )
View Source
var (
MinZero = MinNumber(0)
)
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.