improve validate testing with examples

also simplified structure of test cases and failure logging
This commit is contained in:
Aneurin Barker Snook
2024-07-18 06:53:20 +01:00
parent 4c99b5a654
commit a9c1184d6b
14 changed files with 417 additions and 428 deletions
+2 -2
View File
@@ -10,7 +10,7 @@ var (
func MaxSize[T any](l int) func([]T) error {
return func(value []T) error {
if len(value) > l {
return ErrMustHaveFewerItems
return ErrMustHaveFewerItems.With(l)
}
return nil
}
@@ -20,7 +20,7 @@ func MaxSize[T any](l int) func([]T) error {
func MinSize[T any](l int) func([]T) error {
return func(value []T) error {
if len(value) < l {
return ErrMustHaveMoreItems
return ErrMustHaveMoreItems.With(l)
}
return nil
}