Documentation ¶
Index ¶
- Variables
- func Check(definition Of) error
- func If(expr bool, fn func() error) error
- func Is[T any](value T, validators ...Validator[T]) error
- func Maybe[T any](m monad.Maybe[T], fn func(T) error) error
- func NewError(fieldErrs map[string]error) error
- func Patch[T any](p monad.Patch[T], fn func(T) error) error
- func Value[TRaw, TTarget any](value TRaw, target *TTarget, factory func(TRaw) (TTarget, error)) error
- func WrapIfAppErr(err error, field string, additionalFields ...string) error
- type Error
- type Of
- type Validator
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrValidationFailed = apperr.New("validation_failed")
Functions ¶
func Check ¶
func Check(definition Of) error
Checks a map of label / errors and returns a validation error which contains every errors as needed.
func Patch ¶
Same as Maybe but for monad.Patch. Executes the function only if the value is set and not nil. Looks like I can't pass by an interface to share the logic between Maybe and Patch since Go can't infer the T. I prefer to make the usage easier by duplicating the logic in this specific case. FIXME: When go can infer correctly from an interface [T], merge Maybe and Patch.
Types ¶
Click to show internal directories.
Click to hide internal directories.