Documentation
¶
Overview ¶
Package validator 符合 web.filter 的验证器
Index ¶
- func ASCII(s string) bool
- func After(t time.Time) func(time.Time) bool
- func Alpha(s string) bool
- func And[T any](v ...func(T) bool) func(T) bool
- func BankCard(val string) bool
- func Before(t time.Time) func(time.Time) bool
- func Between[T cmp.Ordered](min, max T) func(T) bool
- func BetweenEqual[T cmp.Ordered](min, max T) func(T) bool
- func CNMobile(val string) bool
- func CNPhone(val string) bool
- func CNTel(val string) bool
- func Digit(val string) bool
- func Email(val string) bool
- func Empty(val string) bool
- func EndWith(suffix string) func(string) bool
- func Equal[T comparable](v T) func(T) bool
- func FileExists(path string) bool
- func FileExistsFS(fsys fs.FS) func(string) bool
- func Great[T cmp.Ordered](num T) func(T) bool
- func GreatEqual[T cmp.Ordered](num T) func(T) bool
- func HTTPStatus(s int) bool
- func Hex(val string) bool
- func HexColor(val string) bool
- func IP(val string) bool
- func IP4(val string) bool
- func IP6(val string) bool
- func ISBN(val string) bool
- func ISBN10(val string) bool
- func ISBN13(val string) bool
- func In[T comparable](element ...T) func(T) bool
- func IsDir(path string) bool
- func IsDirFS(fsys fs.FS) func(string) bool
- func JSON(val []byte) bool
- func LanguageTag(val string) bool
- func Less[T cmp.Ordered](num T) func(T) bool
- func LessEqual[T cmp.Ordered](num T) func(T) bool
- func Luhn(val string) bool
- func MV[M ~map[K]V, K comparable, V any](v func(V) bool, msg web.LocaleStringer) filter.Rule[M]
- func Match(exp *regexp.Regexp) func(string) bool
- func Nil[T any](v T) bool
- func Not[T any](v func(T) bool) func(T) bool
- func NotIn[T comparable](element ...T) func(T) bool
- func Or[T any](v ...func(T) bool) func(T) bool
- func Regexp(v string) bool
- func SV[S ~[]T, T any](v func(T) bool, msg web.LocaleStringer) filter.Rule[S]
- func Semver(ver string) bool
- func SemverCompatible(ver string) func(string) bool
- func SemverGreat(ver string) func(string) bool
- func SemverGreatEqual(ver string) func(string) bool
- func SemverLess(ver string) func(string) bool
- func SemverLessEqual(ver string) func(string) bool
- func StartWith(prefix string) func(string) bool
- func Strength(length, upper, lower, punct, num int8) func(string) bool
- func Timezone(tz string) bool
- func URL(val string) bool
- func UUID(val string) bool
- func V[T any](v func(T) bool, msg web.LocaleStringer) filter.Rule[T]
- func Zero[T any](v T) bool
- func ZeroOr[T comparable](v func(T) bool) func(T) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BetweenEqual ¶
BetweenEqual 判断数值区间 [min, max]
func CNPhone ¶
CNPhone 验证中国大陆的电话号码
支持如下格式:
0578-12345678-1234 057812345678-1234
若存在分机号,则分机号的连接符不能省略。
func GreatEqual ¶
func In ¶
func In[T comparable](element ...T) func(T) bool
In 声明枚举类型的验证规则
要求验证的值必须包含在 element 元素中,如果不存在,则返回 msg 的内容。
func MV ¶
func MV[M ~map[K]V, K comparable, V any](v func(V) bool, msg web.LocaleStringer) filter.Rule[M]
MV 同 filter.MV
func SemverCompatible ¶
SemverCompatible 创建一个验证 [semver] 是否兼容 val 的验证器
func SemverGreatEqual ¶
func SemverLess ¶
func SemverLessEqual ¶
func Strength ¶
Strength 声明密码强度的验证对象
length 对长度的最小要求; upper 对大写字符的最小要求; lower 对小写字符的最小要求; punct 对符号的最小要求; num 对数字的最小要求
详细文档可参考 strength.Strength。
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.