Documentation ¶
Overview ¶
Package validator 符合 web.filter 的验证器
Index ¶
- func ASCII(s string) bool
- func Alpha(s string) bool
- func And[T any](v ...func(T) bool) func(T) bool
- func BankCard(val string) 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 GB11643(val string) bool
- func GB32100(val 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 int) 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 FileExistsFS ¶ added in v0.8.0
FileExistsFS 判断文件是否存在于 fsys
func GB11643 ¶
GB11643 判断一个身份证是否符合 gb11643 标准
若是 15 位则当作一代身份证,仅简单地判断各位是否都是数字; 若是 18 位则当作二代身份证,会计算校验位是否正确;
func GreatEqual ¶
func In ¶
func In[T comparable](element ...T) func(T) bool
In 声明枚举类型的验证规则
要求验证的值必须包含在 element 元素中,如果不存在,则返回 msg 的内容。
func LanguageTag ¶ added in v0.9.0
LanguageTag 是否能解析为 language.Tag 变量
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 ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.