Documentation
¶
Overview ¶
Package validate holds the rules generated Validate methods call and the error type they return. It has no state.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Pattern ¶
Pattern reports whether s matches the anchored regular expression re. Compiled expressions are cached; the set is bounded by the patterns in the schema.
Types ¶
type Errors ¶
type Errors struct {
Fields []FieldError `json:"fields"`
}
Errors is the error a Validate method returns when any rule fails. Its JSON form is what handlers send with status 422.
func (*Errors) MarshalJSON ¶
MarshalJSON renders {"error": "validation", "fields": [...]}.
type FieldError ¶
type FieldError struct {
// Field is the JSON name of the field.
Field string `json:"field"`
// Rule is the rule that failed: required, min, max, email, url,
// pattern, enum, decimal (not a number that fits decimal(p, s)).
Rule string `json:"rule"`
Message string `json:"message"`
}
FieldError is one failed rule on one field.
Click to show internal directories.
Click to hide internal directories.