Documentation
¶
Overview ¶
Package validation provides validation utilities backed by github.com/aatuh/validate/v3.
Public contract:
- Validate and ValidateStruct accept structs or pointers to structs.
- Unsupported targets return toolkit-owned ValidationError values instead of silently succeeding or leaking upstream validator errors.
- ValidateField accepts either Go struct field names or JSON tag names.
- Field errors expose JSON field paths, stable validation codes, and safe human-readable messages.
- Nil contexts are normalized to context.Background().
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewBasicValidator ¶
NewBasicValidator retains the old constructor name and returns the default validate-backed validator.
func NewPlaygroundValidator
deprecated
func NewValidateValidator ¶ added in v3.1.0
NewValidateValidator constructs a validator backed by github.com/aatuh/validate/v3.
Types ¶
type ValidationError ¶
type ValidationError struct {
Field string `json:"field"`
Code string `json:"code,omitempty"`
Message string `json:"message"`
Param any `json:"param,omitempty"`
// Deprecated: Value is retained for source compatibility and is no longer
// populated by this adapter to avoid exposing raw submitted values.
Value string `json:"value,omitempty"`
}
ValidationError represents a validation error with field-specific details.
func (ValidationError) Error ¶
func (e ValidationError) Error() string
func (ValidationError) FieldErrors ¶
func (e ValidationError) FieldErrors() fielderrors.FieldErrors
FieldErrors converts the validation error to standard field errors.
type ValidationErrors ¶
type ValidationErrors struct {
Errors []ValidationError `json:"errors"`
}
ValidationErrors represents multiple validation errors.
func (ValidationErrors) Error ¶
func (e ValidationErrors) Error() string
func (ValidationErrors) FieldErrors ¶
func (e ValidationErrors) FieldErrors() fielderrors.FieldErrors
FieldErrors converts the validation errors to standard field errors.
Click to show internal directories.
Click to hide internal directories.