Documentation
¶
Index ¶
Constants ¶
const ( // TagPreciseResourceStatus is the validation tag for a precise resource status given as // its label or its integer. TagPreciseResourceStatus = "precise_resource_status" // TagPreciseLinkStatus is the validation tag for a precise link status given as its label // or its integer. TagPreciseLinkStatus = "precise_link_status" )
Variables ¶
This section is empty.
Functions ¶
func HTTPMissingValueError ¶ added in v0.9.0
func HTTPMissingValueError(w http.ResponseWriter, location string)
HTTPMissingValueError writes the same response as HTTPValidationError for a single required value that is missing, for a requirement that depends on more than the request body.
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.