validatorV3

package
v1.57.2 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

Types

type Checker added in v1.54.7

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

Checker 验证器

func WithFiber added in v1.54.2

func WithFiber[T any](c *fiber.Ctx, exCheckFns ...any) (form T, checker Checker)

func WithGin added in v1.54.2

func WithGin[T any](c *gin.Context, exCheckFns ...any) (form T, checker Checker)

func (Checker) New added in v1.54.7

func (Checker) New(data any) Checker

func (Checker) OK added in v1.54.16

func (my Checker) OK() bool

func (Checker) Validate added in v1.54.7

func (my Checker) Validate(exCheckFns ...any) Checker

func (Checker) Wrong added in v1.54.7

func (my Checker) Wrong() error

func (Checker) WrongToString added in v1.54.7

func (my Checker) WrongToString(limit string) string

func (Checker) Wrongs added in v1.54.7

func (my Checker) Wrongs() []error

type FieldInfo

type FieldInfo struct {
	Name      string // 字段名
	Value     any    // 实际值
	Kind      reflect.Kind
	Type      reflect.Type
	IsPtr     bool                        // 是否是指针
	IsNil     bool                        // 是否为空指针
	IsZero    bool                        // 是否是零值
	Required  bool                        // 是否必填
	VRuleTags anyArrayV2.AnyArray[string] // v-rule tag 的值
	VNameTags anyArrayV2.AnyArray[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
}

func (*Validator) Checker added in v1.54.7

func (*Validator) Checker(data any) Checker

func (*Validator) GetExFn added in v1.54.7

func (*Validator) GetExFn(key string) func(any) (err error)

func (*Validator) Once added in v1.56.6

func (*Validator) Once() *Validator

func (*Validator) RegisterExFn added in v1.54.11

func (*Validator) RegisterExFn(key string, fn func(any) (err error)) *Validator

Jump to

Keyboard shortcuts

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