Documentation ¶
Index ¶
- Constants
- func IsCIdentifier(value string) bool
- func IsDNS1123Label(value string) bool
- func IsDNS1123Subdomain(value string) bool
- func IsDNS952Label(value string) bool
- func IsQualifiedName(value string) bool
- func IsValidIPv4(value string) bool
- func IsValidLabelValue(value string) bool
- func IsValidPercent(percent string) bool
- func IsValidPortName(port string) bool
- func IsValidPortNum(port int) bool
- func NewErrorTypeMatcher(t ErrorType) utilerrors.Matcher
- type Error
- func NewDuplicateError(field string, value interface{}) *Error
- func NewForbiddenError(field string, value interface{}) *Error
- func NewInternalError(field string, err error) *Error
- func NewInvalidError(field string, value interface{}, detail string) *Error
- func NewNotFoundError(field string, value interface{}) *Error
- func NewNotSupportedError(field string, value interface{}, validValues []string) *Error
- func NewRequiredError(field string) *Error
- func NewTooLongError(field string, value interface{}, maxLength int) *Error
- type ErrorList
- type ErrorType
Constants ¶
const CIdentifierFmt string = "[A-Za-z_][A-Za-z0-9_]*"
const DNS1123LabelFmt string = "[a-z0-9]([-a-z0-9]*[a-z0-9])?"
const DNS1123LabelMaxLength int = 63
const DNS1123SubdomainFmt string = DNS1123LabelFmt + "(\\." + DNS1123LabelFmt + ")*"
const DNS1123SubdomainMaxLength int = 253
const DNS952LabelFmt string = "[a-z]([-a-z0-9]*[a-z0-9])?"
const DNS952LabelMaxLength int = 24
const IdentifierNoHyphensBeginEndFmt string = "[a-z0-9]([a-z0-9-]*[a-z0-9])*"
const LabelValueFmt string = "(" + QualifiedNameFmt + ")?"
const LabelValueMaxLength int = 63
const QualifiedNameFmt string = "(" + qnameCharFmt + qnameExtCharFmt + "*)?" + qnameCharFmt
const QualifiedNameMaxLength int = 63
Variables ¶
This section is empty.
Functions ¶
func IsCIdentifier ¶
IsCIdentifier tests for a string that conforms the definition of an identifier in C. This checks the format, but not the length.
func IsDNS1123Label ¶
IsDNS1123Label tests for a string that conforms to the definition of a label in DNS (RFC 1123).
func IsDNS1123Subdomain ¶
IsDNS1123Subdomain tests for a string that conforms to the definition of a subdomain in DNS (RFC 1123).
func IsDNS952Label ¶
IsDNS952Label tests for a string that conforms to the definition of a label in DNS (RFC 952).
func IsQualifiedName ¶
func IsValidIPv4 ¶
IsValidIPv4 tests that the argument is a valid IPv4 address.
func IsValidLabelValue ¶
func IsValidPercent ¶
func IsValidPortName ¶
IsValidPortName check that the argument is valid syntax. It must be non empty and no more than 15 characters long It must contains at least one letter [a-z] and it must contains only [a-z0-9-]. Hypens ('-') cannot be leading or trailing character of the string and cannot be adjacent to other hyphens. Although RFC 6335 allows upper and lower case characters but case is ignored for comparison purposes: (HTTP and http denote the same service).
func IsValidPortNum ¶
IsValidPortNum tests that the argument is a valid, non-zero port number.
func NewErrorTypeMatcher ¶
func NewErrorTypeMatcher(t ErrorType) utilerrors.Matcher
NewErrorTypeMatcher returns an errors.Matcher that returns true if the provided error is a Error and has the provided ErrorType.
Types ¶
type Error ¶
Error is an implementation of the 'error' interface, which represents a validation error.
func NewDuplicateError ¶
NewDuplicateError returns a *Error indicating "duplicate value". This is used to report collisions of values that must be unique (e.g. names or IDs).
func NewForbiddenError ¶
NewForbiddenError returns a *Error indicating "forbidden". This is used to report valid (as per formatting rules) values which would be accepted under some conditions, but which are not permitted by current conditions (e.g. security policy).
func NewInternalError ¶
NewInternalError returns a *Error indicating "internal error". This is used to signal that an error was found that was not directly related to user input. The err argument must be non-nil.
func NewInvalidError ¶
NewInvalidError returns a *Error indicating "invalid value". This is used to report malformed values (e.g. failed regex match, too long, out of bounds).
func NewNotFoundError ¶
NewNotFoundError returns a *Error indicating "value not found". This is used to report failure to find a requested value (e.g. looking up an ID).
func NewNotSupportedError ¶
NewNotSupportedError returns a *Error indicating "unsupported value". This is used to report unknown values for enumerated fields (e.g. a list of valid values).
func NewRequiredError ¶
NewRequiredError returns a *Error indicating "value required". This is used to report required values that are not provided (e.g. empty strings, null values, or empty arrays).
func NewTooLongError ¶
NewTooLongError returns a *Error indicating "too long". This is used to report that the given value is too long. This is similar to NewInvalidError, but the returned error will not include the too-long value.
type ErrorList ¶
type ErrorList []*Error
ErrorList holds a set of errors.
func (ErrorList) Filter ¶
func (list ErrorList) Filter(fns ...utilerrors.Matcher) ErrorList
Filter removes items from the ErrorList that match the provided fns.
func (ErrorList) Prefix ¶
Prefix adds a prefix to the Field of every Error in the list. Returns the list for convenience.
func (ErrorList) PrefixIndex ¶
PrefixIndex adds an index to the Field of every Error in the list. Returns the list for convenience.
func (ErrorList) ToAggregate ¶
func (list ErrorList) ToAggregate() utilerrors.Aggregate
ToAggregate converts the ErrorList into an errors.Aggregate.
type ErrorType ¶
type ErrorType string
ErrorType 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 ( // ErrorTypeNotFound is used to report failure to find a requested value // (e.g. looking up an ID). See NewNotFoundError. ErrorTypeNotFound ErrorType = "FieldValueNotFound" // ErrorTypeRequired is used to report required values that are not // provided (e.g. empty strings, null values, or empty arrays). See // NewRequiredError. ErrorTypeRequired ErrorType = "FieldValueRequired" // ErrorTypeDuplicate is used to report collisions of values that must be // unique (e.g. unique IDs). See NewDuplicateError. ErrorTypeDuplicate ErrorType = "FieldValueDuplicate" // ErrorTypeInvalid is used to report malformed values (e.g. failed regex // match, too long, out of bounds). See NewInvalidError. ErrorTypeInvalid ErrorType = "FieldValueInvalid" // ErrorTypeNotSupported is used to report unknown values for enumerated // fields (e.g. a list of valid values). See NewNotSupportedError. ErrorTypeNotSupported ErrorType = "FieldValueNotSupported" // ErrorTypeForbidden is used to report valid (as per formatting rules) // values which would be accepted under some conditions, but which are not // permitted by the current conditions (such as security policy). See // NewForbiddenError. ErrorTypeForbidden ErrorType = "FieldValueForbidden" // ErrorTypeTooLong is used to report that the given value is too long. // This is similar to ErrorTypeInvalid, but the error will not include the // too-long value. See NewTooLongError. ErrorTypeTooLong ErrorType = "FieldValueTooLong" // ErrorTypeInternal is used to report other errors that are not related // to user input. ErrorTypeInternal ErrorType = "InternalError" )
TODO: These values are duplicated in api/types.go, but there's a circular dep. Fix it.