alkasir: github.com/alkasir/alkasir/pkg/shared/fielderrors Index | Files

package fielderrors

import "github.com/alkasir/alkasir/pkg/shared/fielderrors"

Index

Package Files

fielderrors.go

func NewValidationErrorFieldPrefixMatcher Uses

func NewValidationErrorFieldPrefixMatcher(prefix string) errors.Matcher

NewValidationErrorFieldPrefixMatcher returns an errors.Matcher that returns true if the provided error is a ValidationError and has a field with the provided prefix.

func NewValidationErrorTypeMatcher Uses

func NewValidationErrorTypeMatcher(t ValidationErrorType) errors.Matcher

NewValidationErrorFieldPrefixMatcher returns an errors.Matcher that returns true if the provided error is a ValidationError and has the provided ValidationErrorType.

type ValidationError Uses

type ValidationError struct {
    Type     ValidationErrorType
    Field    string
    BadValue interface{}
    Detail   string
}

ValidationError is an implementation of the 'error' interface, which represents an error of validation.

func NewFieldDuplicate Uses

func NewFieldDuplicate(field string, value interface{}) *ValidationError

NewFieldDuplicate returns a *ValidationError indicating "duplicate value"

func NewFieldForbidden Uses

func NewFieldForbidden(field string, value interface{}) *ValidationError

NewFieldForbidden returns a *ValidationError indicating "forbidden"

func NewFieldInvalid Uses

func NewFieldInvalid(field string, value interface{}, detail string) *ValidationError

NewFieldInvalid returns a *ValidationError indicating "invalid value"

func NewFieldNotFound Uses

func NewFieldNotFound(field string, value interface{}) *ValidationError

NewFieldNotFound returns a *ValidationError indicating "value not found"

func NewFieldRequired Uses

func NewFieldRequired(field string) *ValidationError

NewFieldRequired returns a *ValidationError indicating "value required"

func NewFieldTooLong Uses

func NewFieldTooLong(field string, value interface{}, maxLength int) *ValidationError

func NewFieldValueNotSupported Uses

func NewFieldValueNotSupported(field string, value interface{}, validValues []string) *ValidationError

NewFieldValueNotSupported returns a *ValidationError indicating "unsupported value"

func (*ValidationError) Error Uses

func (v *ValidationError) Error() string

type ValidationErrorList Uses

type ValidationErrorList []error

func (ValidationErrorList) Filter Uses

func (list ValidationErrorList) Filter(fns ...errors.Matcher) ValidationErrorList

Filter removes items from the ValidationErrorList that match the provided fns.

func (ValidationErrorList) Prefix Uses

func (list ValidationErrorList) Prefix(prefix string) ValidationErrorList

Prefix adds a prefix to the Field of every ValidationError in the list. Returns the list for convenience.

func (ValidationErrorList) PrefixIndex Uses

func (list ValidationErrorList) PrefixIndex(index int) ValidationErrorList

PrefixIndex adds an index to the Field of every ValidationError in the list. Returns the list for convenience.

type ValidationErrorType Uses

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"
    // ValidationErrorTypeForbidden is used to report valid (as per formatting rules)
    // values which would be accepted by some api instances, but which would invoke behavior
    // not permitted by this api instance (such as due to stricter security policy).
    ValidationErrorTypeForbidden ValidationErrorType = "FieldValueForbidden"
    // ValidationErrorTypeTooLong is used to report that given value is too long.
    ValidationErrorTypeTooLong ValidationErrorType = "FieldValueTooLong"
)

TODO: These values are duplicated in api/types.go, but there's a circular dep. Fix it.

func (ValidationErrorType) String Uses

func (t ValidationErrorType) String() string

String converts a ValidationErrorType into its corresponding error message.

Package fielderrors imports 5 packages (graph) and is imported by 3 packages. Updated 2016-07-24. Refresh now. Tools for package owners.