validator

package
v0.11.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CustomizeMap = make(map[string]Rules)

Functions

func ContainsChinese

func ContainsChinese(s string) bool

校验字符串是否包含中文字符

func EmptyToDefault

func EmptyToDefault(str string, defaultStr string) string

EmptyToDefault 如果字符串是"",则返回指定默认字符串,否则返回字符串本身。

func Eq

func Eq(mark string) string

Eq 等于入参(==) 如果为string array Slice则为长度比较 如果是 int uint float 则为数值比较

func Ge

func Ge(mark string) string

Ge 大于等于入参(>=) 如果为string array Slice则为长度比较 如果是 int uint float 则为数值比较

func Gt

func Gt(mark string) string

Gt 大于入参(>) 如果为string array Slice则为长度比较 如果是 int uint float 则为数值比较

func HasEmpty

func HasEmpty(elems []interface{}) (bool, int)

HasEmpty 判断提供的接口数组是否包含空值,并返回空值数量

func IsAllEmpty

func IsAllEmpty(elems []interface{}) bool

IsAllEmpty 判断提供的接口数组是否全是空值

func IsEmptyValue

func IsEmptyValue(v reflect.Value) bool

IsEmptyValue 是否空对象

func IsUndefined

func IsUndefined(str string) bool

IsUndefined 检查字符串是否等于 "undefined"(不区分大小写,忽略前后空格)

func Le

func Le(mark string) string

Le 小于等于入参(<=) 如果为string array Slice则为长度比较 如果是 int uint float 则为数值比较

func Lt

func Lt(mark string) string

Lt 小于入参(<) 如果为string array Slice则为长度比较 如果是 int uint float 则为数值比较

func Ne

func Ne(mark string) string

Ne 不等于入参(!=) 如果为string array Slice则为长度比较 如果是 int uint float 则为数值比较

func NotEmpty

func NotEmpty() string

NotEmpty 非空 不能为其对应类型的0值

func RegexpMatch

func RegexpMatch(rule string) string

RegexpMatch 正则校验 校验输入项是否满足正则表达式

func RegisterRule

func RegisterRule(key string, rule Rules) (err error)

RegisterRule 注册自定义规则方案建议在路由初始化层即注册

func Verify

func Verify(st interface{}, roleMap Rules) (err error)

Verify 校验方法

Types

type Rules

type Rules map[string][]string

type RulesMap

type RulesMap map[string]Rules

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL