validator

package
v0.22.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

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

func IsValidationError(err error) (errorsMap validate.Errors, isErr bool)

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

type ValidationError struct {
	validate.Errors
}

func (ValidationError) Error

func (c ValidationError) Error() string

func (ValidationError) StatusCode

func (c ValidationError) StatusCode() int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL