Documentation
¶
Index ¶
- func ConfiguredValidator(val *validate.Validation, lang string)
- func IsValidationError(err error) (errorsMap validate.Errors, isErr bool)
- func NewStructValidatorConfigured(data any, lang string, scene ...string) *validate.Validation
- func ValidateAndTransform(val *validate.Validation, scene ...string) error
- type NoValidatorWarning
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfiguredValidator ¶ added in v0.21.0
func ConfiguredValidator(val *validate.Validation, lang string)
func IsValidationError ¶ added in v0.21.0
IsValidationError checks if an error is of type ValidationError and extracts the validation errors.
This function takes an error and determines if it is a specific validation error (ValidationError). If it is, returns the validation errors map contained in the error along with true. If it's not, returns nil and false.
Parameters:
- err error: The error to be checked
Returns:
- errorsMap validate.Errors: A map of validation errors if the error is of type ValidationError, nil otherwise
- isErr bool: true if the error is of type ValidationError, false otherwise
Example:
if errorsMap, isValidationErr := validator.IsValidationError(err); isValidationErr {
// Handle validation errors
return HandleValidationErrors(errorsMap)
}
func NewStructValidatorConfigured ¶ added in v0.21.0
func NewStructValidatorConfigured(data any, lang string, scene ...string) *validate.Validation
func ValidateAndTransform ¶ added in v0.21.0
func ValidateAndTransform(val *validate.Validation, scene ...string) error
Types ¶
type NoValidatorWarning ¶ added in v0.21.0
type NoValidatorWarning struct{}
NoValidatorWarning represents a type used to indicate that validation is not implemented in this context. It says you need to use core.Validate function instead
func (NoValidatorWarning) Validate ¶ added in v0.21.0
func (c NoValidatorWarning) Validate(i any) error
type ValidationError ¶
func (ValidationError) Error ¶
func (c ValidationError) Error() string
func (ValidationError) StatusCode ¶
func (c ValidationError) StatusCode() int
Click to show internal directories.
Click to hide internal directories.