Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrorMessageFunc ¶
ErrorMessageFunc is a function that generates an error message for a validation error. It receives the field name and the validation parameter (if any).
type ValidatorService ¶
type ValidatorService struct {
// contains filtered or unexported fields
}
ValidatorService wraps the validator.Validate instance and provides custom validation functionality with user-friendly error messages.
func NewValidatorService ¶
func NewValidatorService() *ValidatorService
NewValidatorService creates a new validation service with default validators.
func (*ValidatorService) RegisterErrorMessage ¶
func (vs *ValidatorService) RegisterErrorMessage(tag string, errorMsgFn ErrorMessageFunc)
RegisterErrorMessage registers or updates an error message for a validation tag. This is useful when you want to customize error messages for built-in validators.
func (*ValidatorService) RegisterValidator ¶
func (vs *ValidatorService) RegisterValidator(tag string, validatorFn validator.Func, errorMsgFn ErrorMessageFunc) error
RegisterValidator registers a custom validator function with its error message. tag: the validation tag to use in struct tags (e.g., "stellar_xdr") validatorFn: the validation function errorMsgFn: the error message function (receives field name and param)