Documentation ¶
Overview ¶
Package validate provides utilities that allow to validate request and response data against OpenAPI Specification parameter and schema definitions.
Note that errors returned from validation functions are generally of type Error, so they can be asserted to corresponding interface(s) to retrieve error's field and value.
errs := validate.Query(ps, q) for _, err := range errs { if e, ok := err.(validate.Error) { field, value := e.Field(), e.Value() // ... } }
Index ¶
Constants ¶
const ( // RFC3339PartialTime is partial-time format as described in RFC3339 // https://xml2rfc.tools.ietf.org/public/rfc/html/rfc3339.html#anchor14 RFC3339PartialTime = "15:04:05" )
Variables ¶
This section is empty.
Functions ¶
func IsPartialTime ¶
IsPartialTime returns true when the string is a valid partial time.
Types ¶
type PartialTime ¶
PartialTime represents a partial-time defined in RFC3339.
swagger:strfmt partial-time
func (PartialTime) MarshalText ¶
func (pt PartialTime) MarshalText() (text []byte, err error)
MarshalText implements encoding.TextMarshaler
func (*PartialTime) UnmarshalText ¶
func (pt *PartialTime) UnmarshalText(text []byte) error
UnmarshalText implements encoding.TextUnmarshaler
type ValidationError ¶
type ValidationError interface { error // Field returns field name where error occurred. Field() string // Value returns original value passed by client on field where error // occurred. Value() interface{} }
ValidationError describes validation error.
func ValidationErrorf ¶
func ValidationErrorf(field string, value interface{}, format string, args ...interface{}) ValidationError
ValidationErrorf returns a new formatted ValidationError.
type ValidationErrors ¶
type ValidationErrors []ValidationError
ValidationErrors is a set of validation errors.
func (ValidationErrors) Errors ¶
func (es ValidationErrors) Errors() []error
Errors returns ValidationErrors in form of Go builtin errors.