Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrorSet ¶
type ErrorSet struct {
// contains filtered or unexported fields
}
Example ¶
subErrSet := NewErrorSet("") subErrSet.AddErr(fmt.Errorf("err"), "PropA") subErrSet.AddErr(fmt.Errorf("err"), "PropB") errSet := NewErrorSet("") errSet.AddErr(fmt.Errorf("err"), "Key") errSet.AddErr(subErrSet.Err(), "Key", 1) errSet.AddErr(NewErrorSet("").Err(), "Key", 1) fmt.Println(errSet.Len()) fmt.Println(errSet)
Output: 3 Key err Key[1].PropA err Key[1].PropB err
func NewErrorSet ¶
func (*ErrorSet) Each ¶
func (errorSet *ErrorSet) Each(cb func(fieldErr *FieldError))
type FieldError ¶
type MissingRequiredFieldError ¶
type MissingRequiredFieldError struct{}
Example ¶
fmt.Println(MissingRequiredFieldError{})
Output: missing required field
func (MissingRequiredFieldError) Error ¶
func (MissingRequiredFieldError) Error() string
type MultipleOfError ¶
type MultipleOfError struct { Target string Current interface{} MultipleOf interface{} }
Example ¶
fmt.Println(&MultipleOfError{ Target: "int value", Current: "11", MultipleOf: 2, })
Output: int value should be multiple of 2, but got invalid value 11
func (*MultipleOfError) Error ¶
func (e *MultipleOfError) Error() string
type NotInEnumError ¶
type NotInEnumError struct { Target string Current interface{} Enums []interface{} }
Example ¶
fmt.Println(&NotInEnumError{ Target: "int value", Current: "11", Enums: []interface{}{ "1", "2", "3", }, })
Output: int value should be one of 1, 2, 3, but got invalid value 11
func (*NotInEnumError) Error ¶
func (e *NotInEnumError) Error() string
type NotMatchError ¶
Example ¶
fmt.Println(&NotMatchError{ Target: "number", Current: "1", Pattern: regexp.MustCompile(`/\d+/`), })
Output: number /\d+/ not match 1
func (*NotMatchError) Error ¶
func (err *NotMatchError) Error() string
type OutOfRangeError ¶
type OutOfRangeError struct { Target string Current interface{} Minimum interface{} Maximum interface{} ExclusiveMaximum bool ExclusiveMinimum bool }
Example ¶
fmt.Println(&OutOfRangeError{ Target: "int value", Minimum: "1", Maximum: "10", Current: "11", ExclusiveMinimum: true, ExclusiveMaximum: true, })
Output: int value should be larger or equal than 1 and less or equal than 10, but got invalid value 11
func (*OutOfRangeError) Error ¶
func (e *OutOfRangeError) Error() string
type SyntaxError ¶
type SyntaxError struct {
Msg string
}
Example ¶
fmt.Println(NewSyntaxError("rule"))
Output: invalid syntax: rule
func NewSyntaxError ¶
func NewSyntaxError(format string, args ...interface{}) *SyntaxError
func (*SyntaxError) Error ¶
func (e *SyntaxError) Error() string
type UnsupportedTypeError ¶
type UnsupportedTypeError struct {
// contains filtered or unexported fields
}
Example ¶
fmt.Println(NewUnsupportedTypeError("string", "@int", "something wrong", "something wrong"))
Output: @int could not validate type string: something wrong; something wrong
func NewUnsupportedTypeError ¶
func NewUnsupportedTypeError(typ string, rule string, msgs ...string) *UnsupportedTypeError
func (*UnsupportedTypeError) Error ¶
func (e *UnsupportedTypeError) Error() string
Click to show internal directories.
Click to hide internal directories.