Files
validate/all.go
T

16 lines
386 B
Go
Raw Normal View History

2023-10-07 13:42:17 +01:00
package validate
2026-09-07 13:59:59 +01:00
// All validates a value against a sequence of validation functions,
// stopping and returning the first error. See Collect to run every
// function and report all failures at once.
2023-10-07 13:42:17 +01:00
func All[T any](fs ...func(T) error) func(T) error {
return func(value T) error {
for _, f := range fs {
if err := f(value); err != nil {
return err
}
}
return nil
}
}