Documentation ¶
Overview ¶
Package errors provides detailed error types for api field validation.
Index ¶
- func FromObject(obj runtime.Object) error
- func IsAlreadyExists(err error) bool
- func IsConflict(err error) bool
- func IsInvalid(err error) bool
- func IsNotFound(err error) bool
- func NewAlreadyExists(kind, name string) error
- func NewConflict(kind, name string, err error) error
- func NewInvalid(kind, name string, errs ErrorList) error
- func NewNotFound(kind, name string) error
- func ValueOf(t ValidationErrorType) string
- type ErrorList
- type ValidationError
- func NewFieldDuplicate(field string, value interface{}) ValidationError
- func NewFieldInvalid(field string, value interface{}) ValidationError
- func NewFieldNotFound(field string, value interface{}) ValidationError
- func NewFieldNotSupported(field string, value interface{}) ValidationError
- func NewFieldRequired(field string, value interface{}) ValidationError
- type ValidationErrorType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromObject ¶
FromObject generates an statusError from an api.Status, if that is the type of obj; otherwise, returns an error created by fmt.Errorf.
func IsAlreadyExists ¶
IsAlreadyExists determines if the err is an error which indicates that a specified resource already exists.
func IsConflict ¶
IsConflict determines if the err is an error which indicates the provided update conflicts.
func IsInvalid ¶
IsInvalid determines if the err is an error which indicates the provided resource is not valid.
func IsNotFound ¶
IsNotFound returns true if the specified error was created by NewNotFoundErr.
func NewAlreadyExists ¶
NewAlreadyExists returns an error indicating the item requested exists by that identifier.
func NewConflict ¶
NewConflict returns an error indicating the item can't be updated as provided.
func NewInvalid ¶
NewInvalid returns an error indicating the item is invalid and cannot be processed.
func NewNotFound ¶
NewNotFound returns a new error which indicates that the resource of the kind and the name was not found.
func ValueOf ¶
func ValueOf(t ValidationErrorType) string
Types ¶
type ErrorList ¶
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 NewFieldDuplicate ¶
func NewFieldDuplicate(field string, value interface{}) ValidationError
NewFieldDuplicate returns a ValidationError indicating "duplicate value"
func NewFieldInvalid ¶
func NewFieldInvalid(field string, value interface{}) ValidationError
NewFieldInvalid returns a ValidationError indicating "invalid value"
func NewFieldNotFound ¶
func NewFieldNotFound(field string, value interface{}) ValidationError
NewFieldNotFound returns a ValidationError indicating "value not found"
func NewFieldNotSupported ¶
func NewFieldNotSupported(field string, value interface{}) ValidationError
NewFieldNotSupported returns a ValidationError indicating "unsupported value"
func NewFieldRequired ¶
func NewFieldRequired(field string, value interface{}) ValidationError
NewFieldRequired 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" )
TODO: These values are duplicated in api/types.go, but there's a circular dep. Fix it.