validatorV3

package
v1.54.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRequired      = errors.New("必填")
	ErrNotBlank      = errors.New("不能为空")
	ErrInvalidLength = errors.New("长度错误")
	ErrInvalidValue  = errors.New("内容错误")
	ErrInvalidFormat = errors.New("格式错误")
	ErrInvalidType   = errors.New("类型错误")
)
View Source
var APP struct {
	Validator     Validator
	ValidatorAttr struct{ Data AttrData }
}

Functions

This section is empty.

Types

type AttrData

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

func (AttrData) Register

func (my AttrData) Register(validator *Validator)

func (AttrData) Set

func (AttrData) Set(data any) ValidatorAttributer

type FieldInfo

type FieldInfo struct {
	Name      string // 字段名
	Value     any    // 实际值
	Kind      reflect.Kind
	IsPtr     bool     // 是否是指针
	IsNil     bool     // 是否为空指针
	Required  bool     // 是否必填
	VRuleTags []string // v-rule tag 的值
	VNameTags []string // v-name tag 的值
	// contains filtered or unexported fields
}

FieldInfo 保存了字段的相关信息。

func (FieldInfo) Check

func (my FieldInfo) Check() FieldInfo

func (FieldInfo) Wrongs

func (my FieldInfo) Wrongs() []error

type FieldRule

type FieldRule struct{ FieldRuleBase }

type FieldRuleBase

type FieldRuleBase struct{ Required string }

type Validator

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

Validator 验证器

func (Validator) New

func (Validator) New(data any) Validator

func (Validator) Validate

func (my Validator) Validate() Validator

func (Validator) Wrongs

func (my Validator) Wrongs() []error

type ValidatorAttributer

type ValidatorAttributer interface{ Register(validator *Validator) }

Jump to

Keyboard shortcuts

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