update all validation tests

This commit is contained in:
Aneurin Barker Snook
2023-11-19 20:42:48 +00:00
parent db902e3c1c
commit 40482060ac
10 changed files with 24 additions and 32 deletions
+5 -1
View File
@@ -1,10 +1,14 @@
package validate
var (
ErrNotEqual = NewError("must be equal to %v")
)
// 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 {
return ErrValueNotAllowed
return ErrNotEqual.With(cmp)
}
return nil
}