Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Checker ¶
type Checker interface {
Check() ErrorGroup
}
Checker represents types that can be checked for validation errors.
type Error ¶
type Error struct { // Unique numeric value that represents a specific type of check error. Code uint32 // Unique human understandable name of the error. Slug string // Full description of the error with any additional context. Desc string }
Error represents the failure of a validation check.
type ErrorGroup ¶
type ErrorGroup interface { error Append(err ...*Error) Errors() []*Error NilWhenEmpty() ErrorGroup Unwrap() error }
ErrorGroup represents a grouping of validation errors.
func RunCheckers ¶
func RunCheckers(checkers ...Checker) ErrorGroup
RunCheckers runs checkers and bundles all errors into a group.
func RunChecks ¶
func RunChecks[T any](val T, checks ...Check[T]) ErrorGroup
RunChecks runs checks for the given value.
If the value is invalid, one or more Errors will be returned.
type Errors ¶
type Errors struct {
// contains filtered or unexported fields
}
Errors represents a slice of Error that implements the ErrorGroup interface.
func (*Errors) NilWhenEmpty ¶
func (e *Errors) NilWhenEmpty() ErrorGroup
NilWhenEmpty will return nil if the instance is nil or doesn't contain any errors. This is helpful for callers to return the result of this function after accumulating errors in a loop.
Interface: ErrorGroup