Documentation ¶
Overview ¶
Package validator defines iam custom binding validators used by gin.
Index ¶
- func GetValidate() *validator.Validate
- func Init(opts *Options)
- func RegisterValidation(tag, errMsg string, vf Validation) error
- func Struct(data interface{}) error
- func StructCtx(ctx context.Context, data interface{}) error
- func Var(f interface{}, rule string) error
- func VarCtx(ctx context.Context, f interface{}, rule string) error
- type FieldError
- type Options
- type Validation
- type ValidationErrors
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetValidate ¶
func GetValidate() *validator.Validate
func RegisterValidation ¶
func RegisterValidation(tag, errMsg string, vf Validation) error
RegisterValidation register custom validation func.
Types ¶
type FieldError ¶
func (*FieldError) Error ¶
func (e *FieldError) Error() string
type Options ¶
type Options struct { Language string `json:"language" mapstructure:"language"` // Struct field tag Tag string `json:"tag" mapstructure:"tag"` }
func NewOptions ¶
func NewOptions() *Options
type Validation ¶
type Validation func(fl validator.FieldLevel) bool
Validation custom validation func.
type ValidationErrors ¶
type ValidationErrors struct {
// contains filtered or unexported fields
}
func (*ValidationErrors) Error ¶
func (e *ValidationErrors) Error() string
func (*ValidationErrors) GetValidatorValidationErrors ¶
func (e *ValidationErrors) GetValidatorValidationErrors() validator.ValidationErrors
func (*ValidationErrors) TranslateErrs ¶
func (e *ValidationErrors) TranslateErrs() (errs []error)
func (*ValidationErrors) TranslateErrsMap ¶
func (e *ValidationErrors) TranslateErrsMap() map[string]string
type Validator ¶
type Validator interface { Struct(data interface{}) error StructCtx(ctx context.Context, data interface{}) error Var(f interface{}, rule string) error VarCtx(ctx context.Context, f interface{}, rule string) error WithTranslator(language string) Validator GetValidate() *validator.Validate RegisterValidation(tag, errMSg string, vf Validation) error }
func WithTranslator ¶
WithTranslator set default translation.
Click to show internal directories.
Click to hide internal directories.