valid

package
v1.30.36 Latest Latest
Warning

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

Go to latest
Published: May 16, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RuleRequired = "required"
	RuleLen      = "len"
	RuleMax      = "max"
	RuleMin      = "min"
	RuleRegex    = "regex"
	RulePhone    = "phone"
	RuleEmail    = "email"
)

Variables

This section is empty.

Functions

func AddRule added in v1.20.7

func AddRule(key string, f func(rule string, data interface{}) error)

AddRule add rule

Types

type Rule added in v1.20.7

type Rule struct {
	// key
	Key string
	// 翻译后的字段名
	// default Key
	Trans string
	// valid
	Valid string
}

func (*Rule) Check added in v1.20.7

func (n *Rule) Check(data interface{}) (err error)

Check rule common rule Check

type ValidError

type ValidError map[string]error

valid type

func Valid

func Valid(data interface{}) ValidError

Valid valid

func ValidModel

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

ValidModel form/single json data

type ValidRule

type ValidRule map[string]*vRule

valid type

func (*ValidRule) String

func (v *ValidRule) String() string

func (*ValidRule) Unmarshal added in v1.30.31

func (v *ValidRule) Unmarshal(str string)

type Validator

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

func (*Validator) Check

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

Check rule

Jump to

Keyboard shortcuts

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