Documentation ¶
Index ¶
- func ValidateStruct(obj any) error
- func ValidateStructCtx(ctx context.Context, obj any) error
- type Option
- func WithTag(s string) Option
- func WithTranslation(tag, text string, override bool) Option
- func WithValidation(tag string, fn validator.Func, callValidationEvenIfNull ...bool) Option
- func WithValidationCtx(tag string, fn validator.FuncCtx, callValidationEvenIfNull ...bool) Option
- func WithValuerType(types ...driver.Valuer) Option
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶
type Option func(v *validator.Validate, trans ut.Translator)
Option 验证器选项
func WithTranslation ¶
WithTranslation 注册自定义错误翻译 参数 `text` 示例:{0}为必填字段 或 {0}必须大于{1}
func WithValidation ¶
WithValidation 注册自定义验证器
func WithValidationCtx ¶
WithValidationCtx 注册带Context的自定义验证器
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator 可被用于Gin框架的验证器 具体支持的验证规则,可以参考:https://pkg.go.dev/github.com/go-playground/validator/v10
func (*Validator) ValidateStruct ¶
ValidateStruct 验证结构体
Click to show internal directories.
Click to hide internal directories.