Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalidStruct = func(err error) error { var out errors.CustomError if ve, ok := err.(validator.ValidationErrors); ok { for _, e := range ve { for _, ie := range strings.Split(e.Error(), "\n") { out, _ = errors.Wrap(out, ie).(errors.CustomError) } } } out, _ = errors.Wrap(out, "invalid struct").(errors.CustomError) return out.WithKind(errors.KindInvalidInput) }
ErrInvalidStruct is the error returned when the struct is invalid.
Functions ¶
This section is empty.
Types ¶
type CustomValidator ¶
type CustomValidator interface { // Tag returns the tag identifier used in struct field validation tags (e.g., `validate:"tag"`). Tag() string // Func returns the validator.Func that performs the validation logic. Func() validator.Func }
CustomValidator defines the interface that custom validators must implement. It requires methods to return the validation tag, function, and translation details.
type Option ¶
type Option func(*val)
Option is a function that configures a Validator.
func WithCustomValidator ¶
func WithCustomValidator(cv CustomValidator) Option
WithCustomValidator adds custom validators to the validator.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.