Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HTTPValidationError ¶
func HTTPValidationError(w http.ResponseWriter, errors validator.ValidationErrors)
HTTPValidationError is a function that writes a slice of validation errors to the response writer in a JSON format.
func JSONTagNameFunc ¶
func JSONTagNameFunc(fld reflect.StructField) string
JSONTagNameFunc is a function that returns the JSON tag name for a field to be used with validate.RegisterTagNameFunc for validators created with the go-playground/validator package.
Types ¶
type FormattedValidationError ¶
type FormattedValidationError struct {
Message string `json:"message"`
Errors []ValidationError `json:"errors"`
}
FormattedValidationError is a struct that represents a formatted validation error that can be returned in responses to clients.
func FormatValidationErrors ¶
func FormatValidationErrors(errors validator.ValidationErrors) *FormattedValidationError
FormatValidationErrors is a function that takes a slice of validation errors and returns a slice of more readable validation errors that can be returned to clients.
type ValidationError ¶
type ValidationError struct {
Location string `json:"location"`
Message string `json:"message"`
Type string `json:"type"`
}
ValidationError is a struct that represents a validation error that can be returned in responses to clients.