Documentation
¶
Overview ¶
Package validation provides comprehensive input validation functions and utilities. It includes struct validation, field validation, and custom validator registration.
Index ¶
- func Email(email string, fieldName string) error
- func InRange(value, minVal, maxVal int64, fieldName string) error
- func Matches(value, pattern, fieldName string) error
- func MaxLength(value string, maxLength int, fieldName string) error
- func MinLength(value string, minLength int, fieldName string) error
- func OneOf(value string, allowed []string, fieldName string) error
- func RegisterCustomValidator(name string, fn func(any) error) error
- func Required(value any, fieldName string) error
- func URL(urlStr string, fieldName string) error
- func UUID(uuidStr string, fieldName string) error
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterCustomValidator ¶
RegisterCustomValidator registers a custom validator function
Types ¶
type ValidationError ¶
ValidationError represents a validation error with field and message details. The type name intentionally matches the package name for clarity in external usage.
func NewValidationError ¶
func NewValidationError(message, field string) ValidationError
NewValidationError creates a new validation error
func ValidateStruct ¶
func ValidateStruct(s any) []ValidationError
ValidateStruct validates a struct based on validate tags
func (ValidationError) Error ¶
func (e ValidationError) Error() string
Error implements the error interface
Click to show internal directories.
Click to hide internal directories.