Documentation ¶
Overview ¶
Package validate contains validation helpers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrBodyRequired = errors.New("body required")
ErrBodyRequired reports that request body is required but server got empty request.
var ErrFieldRequired = errors.New("field required")
ErrFieldRequired reports that field is required, but not found.
Functions ¶
func InvalidContentType ¶ added in v0.11.1
InvalidContentType creates new InvalidContentTypeError.
func UnexpectedStatusCode ¶ added in v0.11.1
UnexpectedStatusCode creates new UnexpectedStatusCode.
Types ¶
type Array ¶
Array validates array length.
func (*Array) SetMaxLength ¶
SetMaxLength sets MaxLength validation.
func (*Array) SetMinLength ¶
SetMinLength sets MinLength validation.
func (Array) ValidateLength ¶
ValidateLength returns error if array length v is invalid.
type FieldError ¶
FieldError is failed validation on field.
type Float ¶ added in v0.16.0
type Float struct { MultipleOf *big.Rat MultipleOfSet bool Min float64 MinSet bool MinExclusive bool Max float64 MaxSet bool MaxExclusive bool }
Float validates float numbers.
func (*Float) SetExclusiveMaximum ¶ added in v0.16.0
SetExclusiveMaximum sets exclusive maximum value.
func (*Float) SetExclusiveMinimum ¶ added in v0.16.0
SetExclusiveMinimum sets exclusive minimum value.
func (*Float) SetMaximum ¶ added in v0.16.0
SetMaximum sets maximum value.
func (*Float) SetMinimum ¶ added in v0.16.0
SetMinimum sets minimum value.
func (*Float) SetMultipleOf ¶ added in v0.16.0
SetMultipleOf sets multipleOf validator.
type Int ¶
type Int struct { MultipleOf uint64 MultipleOfSet bool Min int64 MinSet bool MinExclusive bool Max int64 MaxSet bool MaxExclusive bool }
Int validates integers.
func (*Int) SetExclusiveMaximum ¶
SetExclusiveMaximum sets exclusive maximum value.
func (*Int) SetExclusiveMinimum ¶
SetExclusiveMinimum sets exclusive minimum value.
func (*Int) SetMultipleOf ¶
SetMultipleOf sets multipleOf validator.
type InvalidContentTypeError ¶ added in v0.11.1
type InvalidContentTypeError struct {
ContentType string
}
InvalidContentTypeError reports that decoder got unexpected content type.
func (*InvalidContentTypeError) Error ¶ added in v0.11.1
func (i *InvalidContentTypeError) Error() string
InvalidContentTypeError implements error.
type Object ¶ added in v0.12.0
type Object struct { MinProperties int MinPropertiesSet bool MaxProperties int MaxPropertiesSet bool }
Object validates map length.
func (*Object) SetMaxProperties ¶ added in v0.12.0
SetMaxProperties sets MaxProperties validation.
func (*Object) SetMinProperties ¶ added in v0.12.0
SetMinProperties sets MinProperties validation.
func (Object) ValidateProperties ¶ added in v0.12.0
ValidateProperties returns error if object length (properties number) v is invalid.
type String ¶
type String struct { MinLength int MinLengthSet bool MaxLength int MaxLengthSet bool Email bool Regex *regexp.Regexp Hostname bool }
String validator.
func (*String) SetMaxLength ¶
SetMaxLength sets maximum string length (in Unicode code points).
func (*String) SetMinLength ¶
SetMinLength sets minimum string length (in Unicode code points).
type UnexpectedStatusCodeError ¶ added in v0.11.1
type UnexpectedStatusCodeError struct {
StatusCode int
}
UnexpectedStatusCodeError reports that client got unexpected status code.
func (*UnexpectedStatusCodeError) Error ¶ added in v0.11.1
func (i *UnexpectedStatusCodeError) Error() string
UnexpectedStatusCodeError implements error.