validation

package
v0.2.0-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

ProviderSet is the validator providers.

Functions

func GetExportedFieldNames

func GetExportedFieldNames(obj any) []string

GetExportedFieldNames 返回传入结构体中所有可导出的字段名字.

func ValidRequired

func ValidRequired(obj any, requiredFields ...string) error

ValidRequired 验证结构体中的必需字段是否存在且不为空.

func ValidateAllFields

func ValidateAllFields(obj any, rules Rules) error

func ValidateSelectedFields

func ValidateSelectedFields(obj any, rules Rules, fields ...string) error

通用校验函数

Types

type Rules

type Rules map[string]ValidatorFunc

定义验证规则类型

type Validator

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

Validator implements the validate.IValidator interface.

func NewValidator

func NewValidator(customValidator any) *Validator

NewValidator creates and initializes a custom validator.

func (*Validator) Validate

func (v *Validator) Validate(ctx context.Context, request any) error

Validate validates the request using the appropriate validation method.

type ValidatorFunc

type ValidatorFunc func(value any) error

定义验证函数类型

Jump to

Keyboard shortcuts

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