Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Aggregate ¶
Aggregate represents an object that contains multiple errors, but does not necessarily have singular semantic meaning. The aggregate can be used with `errors.Is()` to check for the occurrence of a specific error type. Errors.As() is not supported, because the caller presumably cares about a specific error of potentially multiple that match the given type.
func NewAggregate ¶
NewAggregate converts a slice of errors into an Aggregate interface, which is itself an implementation of the error interface. If the slice is empty, this returns nil. It will check if any of the element of input error list is nil, to avoid nil pointer panic when call Error().
type Error ¶
Error is an implementation of the 'error' interface, which represents a field-level validation error.
func Invalid ¶
Invalid returns a *Error indicating "invalid value". This is used to report malformed values (e.g. failed regex match, too long, out of bounds).
func NotSupported ¶
NotSupported returns a *Error indicating "unsupported value". This is used to report unknown values for enumerated fields (e.g. a list of valid values).
type ErrorList ¶
type ErrorList []*Error
ErrorList holds a set of Errors.
func (ErrorList) ToAggregate ¶
ToAggregate converts the ErrorList into an Aggregate.
type ErrorType ¶
type ErrorType string
ErrorType is a machine readable value providing more detail about why a field is invalid.
const ( // ErrorTypeInvalid is used to report malformed values (e.g. failed regex // match, too long, out of bounds). See Invalid(). ErrorTypeInvalid ErrorType = "FieldValueInvalid" // ErrorTypeNotSupported is used to report unknown values for enumerated // fields (e.g. a list of valid values). See NotSupported(). ErrorTypeNotSupported ErrorType = "FieldValueNotSupported" // ErrorTypeInternal is used to report other errors that are not related // to user input. ErrorTypeInternal ErrorType = "InternalError" )
type Path ¶
type Path struct {
// contains filtered or unexported fields
}
Path represents the path from some root to a particular field.
func (*Path) Index ¶
Index indicates that the previous Path is to be subscripted by an int. This sets the same underlying value as Key.