validator

package
v1.7.8 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Valid

func Valid(data, model interface{}) *result.MapData

创建校验器对象 针对form表单/json数据两种

Types

type DefaultRule

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

内置规则结构 实现ValidateRuler接口

func (*DefaultRule) Check

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

字段值转换成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 map[string]error)

执行检查

func (*Validator) CheckInfo

func (v *Validator) CheckInfo() *result.MapData

执行检查后返回信息 trans 翻译后的字段名

Jump to

Keyboard shortcuts

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