Files
validate/equal.go
T

16 lines
300 B
Go
Raw Normal View History

2023-10-12 19:55:08 +01:00
package validate
2023-11-19 20:42:48 +00:00
var (
ErrNotEqual = NewError("must be equal to %v")
)
2023-10-12 19:55:08 +01:00
// Equal validates whether an input value is equal to a comparison value.
func Equal[T comparable](cmp T) func(T) error {
return func(value T) error {
if value != cmp {
2023-11-19 20:42:48 +00:00
return ErrNotEqual.With(cmp)
2023-10-12 19:55:08 +01:00
}
return nil
}
}