|
|
@ -11137,7 +11137,7 @@ func TestExcludedUnless(t *testing.T) { |
|
|
|
FieldE string `validate:"omitempty" json:"field_e"` |
|
|
|
FieldE string `validate:"omitempty" json:"field_e"` |
|
|
|
FieldER string `validate:"excluded_unless=FieldE test" json:"field_er"` |
|
|
|
FieldER string `validate:"excluded_unless=FieldE test" json:"field_er"` |
|
|
|
}{ |
|
|
|
}{ |
|
|
|
FieldE: "notest", |
|
|
|
FieldE: "test", |
|
|
|
FieldER: "filled", |
|
|
|
FieldER: "filled", |
|
|
|
} |
|
|
|
} |
|
|
|
errs := validate.Struct(test) |
|
|
|
errs := validate.Struct(test) |
|
|
@ -11147,7 +11147,7 @@ func TestExcludedUnless(t *testing.T) { |
|
|
|
FieldE string `validate:"omitempty" json:"field_e"` |
|
|
|
FieldE string `validate:"omitempty" json:"field_e"` |
|
|
|
FieldER string `validate:"excluded_unless=FieldE test" json:"field_er"` |
|
|
|
FieldER string `validate:"excluded_unless=FieldE test" json:"field_er"` |
|
|
|
}{ |
|
|
|
}{ |
|
|
|
FieldE: "test", |
|
|
|
FieldE: "notest", |
|
|
|
FieldER: "filled", |
|
|
|
FieldER: "filled", |
|
|
|
} |
|
|
|
} |
|
|
|
errs = validate.Struct(test2) |
|
|
|
errs = validate.Struct(test2) |
|
|
@ -11156,7 +11156,7 @@ func TestExcludedUnless(t *testing.T) { |
|
|
|
Equal(t, len(ve), 1) |
|
|
|
Equal(t, len(ve), 1) |
|
|
|
AssertError(t, errs, "FieldER", "FieldER", "FieldER", "FieldER", "excluded_unless") |
|
|
|
AssertError(t, errs, "FieldER", "FieldER", "FieldER", "FieldER", "excluded_unless") |
|
|
|
|
|
|
|
|
|
|
|
shouldError := "test" |
|
|
|
shouldError := "notest" |
|
|
|
test3 := struct { |
|
|
|
test3 := struct { |
|
|
|
Inner *Inner |
|
|
|
Inner *Inner |
|
|
|
Field1 string `validate:"excluded_unless=Inner.Field test" json:"field_1"` |
|
|
|
Field1 string `validate:"excluded_unless=Inner.Field test" json:"field_1"` |
|
|
@ -11170,7 +11170,7 @@ func TestExcludedUnless(t *testing.T) { |
|
|
|
Equal(t, len(ve), 1) |
|
|
|
Equal(t, len(ve), 1) |
|
|
|
AssertError(t, errs, "Field1", "Field1", "Field1", "Field1", "excluded_unless") |
|
|
|
AssertError(t, errs, "Field1", "Field1", "Field1", "Field1", "excluded_unless") |
|
|
|
|
|
|
|
|
|
|
|
shouldPass := "shouldPass" |
|
|
|
shouldPass := "test" |
|
|
|
test4 := struct { |
|
|
|
test4 := struct { |
|
|
|
Inner *Inner |
|
|
|
Inner *Inner |
|
|
|
FieldE string `validate:"omitempty" json:"field_e"` |
|
|
|
FieldE string `validate:"omitempty" json:"field_e"` |
|
|
@ -12264,25 +12264,25 @@ func TestCreditCardFormatValidation(t *testing.T) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestMultiOrOperatorGroup(t *testing.T) { |
|
|
|
func TestMultiOrOperatorGroup(t *testing.T) { |
|
|
|
tests := []struct { |
|
|
|
tests := []struct { |
|
|
|
Value int `validate:"eq=1|gte=5,eq=1|lt=7"` |
|
|
|
Value int `validate:"eq=1|gte=5,eq=1|lt=7"` |
|
|
|
expected bool |
|
|
|
expected bool |
|
|
|
}{ |
|
|
|
}{ |
|
|
|
{1, true}, {2, false}, {5, true}, {6, true}, {8, false}, |
|
|
|
{1, true}, {2, false}, {5, true}, {6, true}, {8, false}, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
validate := New() |
|
|
|
validate := New() |
|
|
|
|
|
|
|
|
|
|
|
for i, test := range tests { |
|
|
|
for i, test := range tests { |
|
|
|
errs := validate.Struct(test) |
|
|
|
errs := validate.Struct(test) |
|
|
|
if test.expected { |
|
|
|
if test.expected { |
|
|
|
if !IsEqual(errs, nil) { |
|
|
|
if !IsEqual(errs, nil) { |
|
|
|
t.Fatalf("Index: %d multi_group_of_OR_operators failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d multi_group_of_OR_operators failed Error: %s", i, errs) |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
t.Fatalf("Index: %d multi_group_of_OR_operators should have errs", i) |
|
|
|
t.Fatalf("Index: %d multi_group_of_OR_operators should have errs", i) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|