Documentation
¶
Index ¶
- func FormatError(err error) error
- func RegisterValidation(f func(v *validator.Validate, translator ut.Translator))
- func Struct(s any) error
- func StructCtx(ctx context.Context, s any) error
- func StructExceptCtx(ctx context.Context, s any, omitField ...string) error
- func Translator() ut.Translator
- func Validate() *validator.Validate
- type EnumValuer
- type FieldError
- type ValidEnum
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatError ¶
FormatError formats validator errors using the universal translator
func RegisterValidation ¶
func RegisterValidation(f func(v *validator.Validate, translator ut.Translator))
RegisterValidation registers a custom validation with translation
func StructExceptCtx ¶
StructExceptCtx validates a struct with context, omitting specified fields
func Translator ¶
func Translator() ut.Translator
Translator returns the universal translator instance
Types ¶
type EnumValuer ¶ added in v0.1.2
type EnumValuer interface {
Values() []string
}
EnumValuer is optionally implemented by enums that can list their valid values. When implemented, validation error messages will include the allowed values.
type FieldError ¶
FieldError represents a single field validation error
type ValidEnum ¶ added in v0.1.2
type ValidEnum interface {
IsValid() bool
}
ValidEnum is implemented by enum types that can validate their value.
type ValidationError ¶
type ValidationError struct {
Message string `json:"message"`
FieldErrors []FieldError `json:"fieldErrors"`
}
ValidationError represents validation errors
func (ValidationError) Error ¶
func (v ValidationError) Error() string
Click to show internal directories.
Click to hide internal directories.