|
|
@ -71,6 +71,7 @@ type TestString struct { |
|
|
|
Gt string `validate:"gt=10"` |
|
|
|
Gt string `validate:"gt=10"` |
|
|
|
Gte string `validate:"gte=10"` |
|
|
|
Gte string `validate:"gte=10"` |
|
|
|
OmitEmpty string `validate:"omitempty,min=1,max=10"` |
|
|
|
OmitEmpty string `validate:"omitempty,min=1,max=10"` |
|
|
|
|
|
|
|
Boolean string `validate:"boolean"` |
|
|
|
Sub *SubTest |
|
|
|
Sub *SubTest |
|
|
|
SubIgnore *SubTest `validate:"-"` |
|
|
|
SubIgnore *SubTest `validate:"-"` |
|
|
|
Anonymous struct { |
|
|
|
Anonymous struct { |
|
|
@ -7943,6 +7944,7 @@ func TestStructStringValidation(t *testing.T) { |
|
|
|
Lte: "0123456789", |
|
|
|
Lte: "0123456789", |
|
|
|
Gt: "01234567890", |
|
|
|
Gt: "01234567890", |
|
|
|
Gte: "0123456789", |
|
|
|
Gte: "0123456789", |
|
|
|
|
|
|
|
Boolean: "true", |
|
|
|
OmitEmpty: "", |
|
|
|
OmitEmpty: "", |
|
|
|
Sub: &SubTest{ |
|
|
|
Sub: &SubTest{ |
|
|
|
Test: "1", |
|
|
|
Test: "1", |
|
|
@ -7974,6 +7976,7 @@ func TestStructStringValidation(t *testing.T) { |
|
|
|
Gt: "1", |
|
|
|
Gt: "1", |
|
|
|
Gte: "1", |
|
|
|
Gte: "1", |
|
|
|
OmitEmpty: "12345678901", |
|
|
|
OmitEmpty: "12345678901", |
|
|
|
|
|
|
|
Boolean: "nope", |
|
|
|
Sub: &SubTest{ |
|
|
|
Sub: &SubTest{ |
|
|
|
Test: "", |
|
|
|
Test: "", |
|
|
|
}, |
|
|
|
}, |
|
|
@ -7991,7 +7994,7 @@ func TestStructStringValidation(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
// Assert Top Level
|
|
|
|
// Assert Top Level
|
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 13) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 14) |
|
|
|
|
|
|
|
|
|
|
|
// Assert Fields
|
|
|
|
// Assert Fields
|
|
|
|
AssertError(t, errs, "TestString.Required", "TestString.Required", "Required", "Required", "required") |
|
|
|
AssertError(t, errs, "TestString.Required", "TestString.Required", "Required", "Required", "required") |
|
|
@ -8004,6 +8007,7 @@ func TestStructStringValidation(t *testing.T) { |
|
|
|
AssertError(t, errs, "TestString.Gt", "TestString.Gt", "Gt", "Gt", "gt") |
|
|
|
AssertError(t, errs, "TestString.Gt", "TestString.Gt", "Gt", "Gt", "gt") |
|
|
|
AssertError(t, errs, "TestString.Gte", "TestString.Gte", "Gte", "Gte", "gte") |
|
|
|
AssertError(t, errs, "TestString.Gte", "TestString.Gte", "Gte", "Gte", "gte") |
|
|
|
AssertError(t, errs, "TestString.OmitEmpty", "TestString.OmitEmpty", "OmitEmpty", "OmitEmpty", "max") |
|
|
|
AssertError(t, errs, "TestString.OmitEmpty", "TestString.OmitEmpty", "OmitEmpty", "OmitEmpty", "max") |
|
|
|
|
|
|
|
AssertError(t, errs, "TestString.Boolean", "TestString.Boolean", "Boolean", "Boolean", "boolean") |
|
|
|
|
|
|
|
|
|
|
|
// Nested Struct Field Errs
|
|
|
|
// Nested Struct Field Errs
|
|
|
|
AssertError(t, errs, "TestString.Anonymous.A", "TestString.Anonymous.A", "A", "A", "required") |
|
|
|
AssertError(t, errs, "TestString.Anonymous.A", "TestString.Anonymous.A", "A", "A", "required") |
|
|
|