add validate.Equal

This commit is contained in:
Aneurin Barker Snook
2023-10-12 19:55:08 +01:00
parent 1cb434327a
commit 9537961e29
3 changed files with 91 additions and 27 deletions
+11
View File
@@ -0,0 +1,11 @@
package validate
// 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 nil
}
}