validator

package
v0.0.0-...-a2093d6 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2022 License: LGPL-2.1 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NotNull validateType = iota
)

Variables

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

Functions

func Eq

func Eq(mark string) string

func Ge

func Ge(mark string) string

func Gt

func Gt(mark string) string

func In

func In(mark string) string

In 判断值是否是其中一个 用逗号隔开

func Le

func Le(mark string) string

func Lt

func Lt(mark string) string

func Ne

func Ne(mark string) string

func NotEmpty

func NotEmpty() string

func RegexpMatch

func RegexpMatch(rule string) string

@author: [zooqkl](https://github.com/zooqkl) @function: RegexpMatch @description: 正则校验 校验输入项是否满足正则表达式 @param: rule string @return: string

func RegisterRule

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

func ValidatorField

func ValidatorField(field *FieldMeta) error

func Verify

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

Types

type FieldMeta

type FieldMeta struct {
	Name     string            // 字段名
	NickName string            // 可能由json等指定
	Tag      map[string]string // 标签 按照空格分割
	Value    reflect.Value     // 字段值
	Type     reflect.Type      // 字段的类型
}

func IterStructField

func IterStructField(data interface{}) []*FieldMeta

返回结构体的所有字段、值、tag

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