Documentation
¶
Index ¶
- func ValueOf(t ValidationErrorType) string
- type ErrorList
- type ValidationError
- func NewDuplicate(field string, value interface{}) ValidationError
- func NewInvalid(field string, value interface{}) ValidationError
- func NewNotFound(field string, value interface{}) ValidationError
- func NewNotSupported(field string, value interface{}) ValidationError
- func NewRequired(field string, value interface{}) ValidationError
- type ValidationErrorType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValueOf ¶
func ValueOf(t ValidationErrorType) string
Types ¶
type ErrorList ¶
type ErrorList []error
ErrorList is a collection of errors. This does not implement the error interface to avoid confusion where an empty ErrorList would still be an error (non-nil). To produce a single error instance from an ErrorList, use the ToError() method, which will return nil for an empty ErrorList.
func (ErrorList) Prefix ¶
Prefix adds a prefix to the Field of every ValidationError in the list. Returns the list for convenience.
func (ErrorList) PrefixIndex ¶
PrefixIndex adds an index to the Field of every ValidationError in the list. Returns the list for convenience.
type ValidationError ¶
type ValidationError struct { Type ValidationErrorType Field string BadValue interface{} }
ValidationError is an implementation of the 'error' interface, which represents an error of validation.
func NewDuplicate ¶
func NewDuplicate(field string, value interface{}) ValidationError
NewDuplicate returns a ValidationError indicating "duplicate value"
func NewInvalid ¶
func NewInvalid(field string, value interface{}) ValidationError
NewInvalid returns a ValidationError indicating "invalid value"
func NewNotFound ¶
func NewNotFound(field string, value interface{}) ValidationError
NewNotFound returns a ValidationError indicating "value not found"
func NewNotSupported ¶
func NewNotSupported(field string, value interface{}) ValidationError
NewNotSupported returns a ValidationError indicating "unsupported value"
func NewRequired ¶
func NewRequired(field string, value interface{}) ValidationError
NewInvalid returns a ValidationError indicating "value required"
func (ValidationError) Error ¶
func (v ValidationError) Error() string
type ValidationErrorType ¶
type ValidationErrorType string
ValidationErrorType is a machine readable value providing more detail about why a field is invalid. These values are expected to match 1-1 with CauseType in api/types.go.
const ( // ValidationErrorTypeNotFound is used to report failure to find a requested value // (e.g. looking up an ID). ValidationErrorTypeNotFound ValidationErrorType = "fieldValueNotFound" // ValidationErrorTypeRequired is used to report required values that are not // provided (e.g. empty strings, null values, or empty arrays). ValidationErrorTypeRequired ValidationErrorType = "fieldValueRequired" // ValidationErrorTypeDuplicate is used to report collisions of values that must be // unique (e.g. unique IDs). ValidationErrorTypeDuplicate ValidationErrorType = "fieldValueDuplicate" // ValidationErrorTypeInvalid is used to report malformed values (e.g. failed regex // match). ValidationErrorTypeInvalid ValidationErrorType = "fieldValueInvalid" // ValidationErrorTypeNotSupported is used to report valid (as per formatting rules) // values that can not be handled (e.g. an enumerated string). ValidationErrorTypeNotSupported ValidationErrorType = "fieldValueNotSupported" )