validatorV3

package
v1.54.3 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: 14 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
	ValidatorEx ValidatorEx
}

Functions

This section is empty.

Types

type FieldInfo

type FieldInfo struct {
	Name      string // 字段名
	Value     any    // 实际值
	Kind      reflect.Kind
	Type      reflect.Type
	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 WithFiber added in v1.54.2

func WithFiber[T any](c *fiber.Ctx, exCheckFns ...any) Validator

func WithGin added in v1.54.2

func WithGin[T any](c *gin.Context, exCheckFns ...any) Validator

func (Validator) New

func (Validator) New(data any) Validator

func (Validator) Validate

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

func (Validator) WrongToString added in v1.54.2

func (my Validator) WrongToString() string

func (Validator) Wrongs

func (my Validator) Wrongs() []error

type ValidatorEx added in v1.54.3

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

func (*ValidatorEx) Get added in v1.54.3

func (*ValidatorEx) Get(key string) func(any) error

func (*ValidatorEx) New added in v1.54.3

func (*ValidatorEx) New() *ValidatorEx

func (*ValidatorEx) Register added in v1.54.3

func (*ValidatorEx) Register(key string, fn func(any) error) *ValidatorEx

Jump to

Keyboard shortcuts

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