diff --git a/builtin.go b/builtin.go index 94d1b36..4c7734e 100644 --- a/builtin.go +++ b/builtin.go @@ -29,14 +29,14 @@ func (s Schema) Validate(field *Field) (errs Errors) { } // Value is a shortcut function used to create a schema for a simple value. -func Value(value interface{}, validator Validator) Schema { +func Value(value any, validator Validator) Schema { return Schema{ F("", value): validator, } } // Nested is a composite validator factory used to create a validator, which will -// delegate the actual validation to the schema returned by f. +// delegate the actual validation to the validator returned by f. func Nested[T any](f func(T) Validator) Validator { return Func(func(field *Field) Errors { v, ok := field.Value.(T) @@ -49,7 +49,7 @@ func Nested[T any](f func(T) Validator) Validator { } // Map is a composite validator factory used to create a validator, which will -// do the validation per the key/value schemas associated with a map. +// do the validation per the schemas associated with a map. func Map[T map[K]V, K comparable, V any](f func(T) map[K]Schema) Validator { return Func(func(field *Field) (errs Errors) { v, ok := field.Value.(T) diff --git a/builtin_test.go b/builtin_test.go index f4e96ec..dfbe0f1 100644 --- a/builtin_test.go +++ b/builtin_test.go @@ -24,7 +24,7 @@ func makeErrsMap(errs v.Errors) map[string]v.Error { func TestNested(t *testing.T) { cases := []struct { name string - value interface{} + value any validator v.Validator errs v.Errors }{ @@ -66,7 +66,7 @@ func TestMap(t *testing.T) { cases := []struct { name string - value interface{} + value any validator v.Validator errs v.Errors }{ @@ -136,7 +136,7 @@ func TestSlice(t *testing.T) { cases := []struct { name string - value interface{} + value any validator v.Validator errs v.Errors }{ @@ -335,7 +335,7 @@ func TestNot(t *testing.T) { func TestIs(t *testing.T) { cases := []struct { name string - value interface{} + value any validator v.Validator errs v.Errors }{ @@ -378,7 +378,7 @@ func TestIs(t *testing.T) { func TestNonzero(t *testing.T) { cases := []struct { - value interface{} + value any validator v.Validator errs v.Errors }{ @@ -445,7 +445,7 @@ func TestNonzero(t *testing.T) { func TestZero(t *testing.T) { cases := []struct { - value interface{} + value any validator v.Validator errs v.Errors }{ @@ -512,7 +512,7 @@ func TestZero(t *testing.T) { func TestLenString(t *testing.T) { cases := []struct { - value interface{} + value any validator v.Validator errs v.Errors }{ @@ -549,7 +549,7 @@ func TestLenString(t *testing.T) { func TestLenSlice(t *testing.T) { cases := []struct { - value interface{} + value any validator v.Validator errs v.Errors }{ @@ -601,7 +601,7 @@ func TestLenSlice(t *testing.T) { func TestRuneCount(t *testing.T) { cases := []struct { - value interface{} + value any validator v.Validator errs v.Errors }{ @@ -1062,7 +1062,7 @@ func TestIn_Nin(t *testing.T) { func TestMatch(t *testing.T) { cases := []struct { name string - value interface{} + value any validator v.Validator errs v.Errors }{ diff --git a/validating.go b/validating.go index edef7c4..7e2bc83 100644 --- a/validating.go +++ b/validating.go @@ -3,11 +3,11 @@ package validating // Field represents a (Name, Value) pair that needs to be validated. type Field struct { Name string - Value interface{} + Value any } // F is a shortcut for creating a pointer to Field. -func F(name string, value interface{}) *Field { +func F(name string, value any) *Field { return &Field{Name: name, Value: value} }