valid

package
v1.9.6 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultRule

type DefaultRule struct {
	// 验证的字段名
	Key string
	// 翻译后的字段名
	// 默认 = Key
	Trans string
	// 规则
	Valid string
}

内置规则结构 实现ValidateRuler接口

func (*DefaultRule) Check

func (n *DefaultRule) Check(data interface{}) (err error)
common rule

字段值转换成string进行验证

type ValidError

type ValidError map[string]error

valid error

func Valid

func Valid(data interface{}) ValidError

创建校验器对象 针对结构体数据 json

func ValidModel

func ValidModel(data interface{}, model interface{}) ValidError

form/single json data

type ValidRule

type ValidRule map[string]*vRule

valid error

func (*ValidRule) String

func (v *ValidRule) String() string

func (*ValidRule) Struct

func (v *ValidRule) Struct(str string)

type ValidateRuler

type ValidateRuler interface {
	// 验证字段
	Check(data interface{}) error
}

校验规则接口 支持自定义规则

type Validator

type Validator struct {
	// contains filtered or unexported fields
}

func (*Validator) Check

func (v *Validator) Check() (errs ValidError)

执行检查

Jump to

Keyboard shortcuts

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