Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalidField = errors.New("invalid field")
View Source
var ErrInvalidStruct = errors.New("invalid struct")
Functions ¶
Types ¶
type FieldError ¶
type FieldError struct {
Namespace string `json:"namespace"` // can differ when a custom TagNameFunc is registered or
Field string `json:"field"` // by passing alt name to ReportError like below
StructNamespace string `json:"structNamespace"`
StructField string `json:"structField"`
Tag string `json:"tag"`
ActualTag string `json:"actualTag"`
Kind string `json:"kind"`
Type string `json:"type"`
Value string `json:"value"`
Param string `json:"param"`
Message string `json:"message"`
}
FieldError is a particular validation error on a particular field.
type StructError ¶
type StructError struct {
Fields []FieldError
}
StructError contains validation errors on individual fields in a struct.
func ValidateStruct ¶
func ValidateStruct(s any) *StructError
ValidateStruct performs validation on the given struct. If validation fails, a non-nil error is returned that contains the details of individual field validation issues.
func (*StructError) Error ¶
func (e *StructError) Error() string
Error satisfies the Error interface.
Click to show internal directories.
Click to hide internal directories.