Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterNullValueTypeFunc ¶
func RegisterNullValueTypeFunc[T any]()
RegisterNullValueTypeFunc registers a type function for null.Value[T] types.
func RegisterTypeFunc ¶
func RegisterTypeFunc(fn CustomTypeFunc, types ...any)
RegisterTypeFunc registers a custom type function for specified types.
func RegisterValidationRules ¶
func RegisterValidationRules(rules ...ValidationRule) error
RegisterValidationRules registers custom validation rules.
Types ¶
type CustomTypeFunc ¶
CustomTypeFunc defines a custom type function for validation that extracts values from custom types.
type ValidationRule ¶
type ValidationRule struct {
RuleTag string // RuleTag is the unique identifier for the validation rule (used in struct tags)
ErrMessageTemplate string // ErrMessageTemplate is the error message template with placeholders like {0}, {1} (used as fallback)
ErrMessageI18nKey string // ErrMessageI18nKey is the i18n key for the error message (optional, takes precedence over ErrMessageTemplate)
Validate func(fl v.FieldLevel) bool // Validate performs the actual validation logic and returns true if valid
ParseParam func(fe v.FieldError) []string // ParseParam extracts parameters from FieldError for error message formatting
CallValidationEvenIfNull bool // CallValidationEvenIfNull determines whether to validate nil/zero values
}
ValidationRule defines a custom validation rule with translation support.
Click to show internal directories.
Click to hide internal directories.