|
|
@ -113,7 +113,9 @@ type TestSlice struct { |
|
|
|
|
|
|
|
|
|
|
|
var validate = New(Config{TagName: "validate"}) |
|
|
|
var validate = New(Config{TagName: "validate"}) |
|
|
|
|
|
|
|
|
|
|
|
func AssertError(t *testing.T, errs ValidationErrors, key, field, expectedTag string) { |
|
|
|
func AssertError(t *testing.T, err error, key, field, expectedTag string) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
errs := err.(ValidationErrors) |
|
|
|
|
|
|
|
|
|
|
|
val, ok := errs[key] |
|
|
|
val, ok := errs[key] |
|
|
|
EqualSkip(t, 2, ok, true) |
|
|
|
EqualSkip(t, 2, ok, true) |
|
|
@ -242,7 +244,7 @@ func TestAliasTags(t *testing.T) { |
|
|
|
errs = validate.Struct(tst) |
|
|
|
errs = validate.Struct(tst) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
AssertError(t, errs, "Test.Color", "Color", "iscolor") |
|
|
|
AssertError(t, errs, "Test.Color", "Color", "iscolor") |
|
|
|
Equal(t, errs["Test.Color"].ActualTag, "hexcolor|rgb|rgba|hsl|hsla") |
|
|
|
Equal(t, errs.(ValidationErrors)["Test.Color"].ActualTag, "hexcolor|rgb|rgba|hsl|hsla") |
|
|
|
|
|
|
|
|
|
|
|
validate.RegisterAliasValidation("req", "required,dive,iscolor") |
|
|
|
validate.RegisterAliasValidation("req", "required,dive,iscolor") |
|
|
|
arr := []string{"val1", "#fff", "#000"} |
|
|
|
arr := []string{"val1", "#fff", "#000"} |
|
|
@ -397,12 +399,12 @@ func TestStructPartial(t *testing.T) { |
|
|
|
// these will fail as unset item IS tested
|
|
|
|
// these will fail as unset item IS tested
|
|
|
|
errs = validate.StructExcept(tPartial, p1...) |
|
|
|
errs = validate.StructExcept(tPartial, p1...) |
|
|
|
AssertError(t, errs, "TestPartial.SubSlice[0].Test", "Test", "required") |
|
|
|
AssertError(t, errs, "TestPartial.SubSlice[0].Test", "Test", "required") |
|
|
|
Equal(t, len(errs), 1) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 1) |
|
|
|
|
|
|
|
|
|
|
|
errs = validate.StructPartial(tPartial, p2...) |
|
|
|
errs = validate.StructPartial(tPartial, p2...) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
AssertError(t, errs, "TestPartial.SubSlice[0].Test", "Test", "required") |
|
|
|
AssertError(t, errs, "TestPartial.SubSlice[0].Test", "Test", "required") |
|
|
|
Equal(t, len(errs), 1) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 1) |
|
|
|
|
|
|
|
|
|
|
|
// Unset second slice member concurrently to test dive behavior:
|
|
|
|
// Unset second slice member concurrently to test dive behavior:
|
|
|
|
tPartial.SubSlice[1].Test = "" |
|
|
|
tPartial.SubSlice[1].Test = "" |
|
|
@ -417,13 +419,13 @@ func TestStructPartial(t *testing.T) { |
|
|
|
AssertError(t, errs, "TestPartial.SubSlice[1].Test", "Test", "required") |
|
|
|
AssertError(t, errs, "TestPartial.SubSlice[1].Test", "Test", "required") |
|
|
|
|
|
|
|
|
|
|
|
errs = validate.StructExcept(tPartial, p1...) |
|
|
|
errs = validate.StructExcept(tPartial, p1...) |
|
|
|
Equal(t, len(errs), 2) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 2) |
|
|
|
AssertError(t, errs, "TestPartial.SubSlice[0].Test", "Test", "required") |
|
|
|
AssertError(t, errs, "TestPartial.SubSlice[0].Test", "Test", "required") |
|
|
|
AssertError(t, errs, "TestPartial.SubSlice[1].Test", "Test", "required") |
|
|
|
AssertError(t, errs, "TestPartial.SubSlice[1].Test", "Test", "required") |
|
|
|
|
|
|
|
|
|
|
|
errs = validate.StructPartial(tPartial, p2...) |
|
|
|
errs = validate.StructPartial(tPartial, p2...) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
Equal(t, len(errs), 1) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 1) |
|
|
|
AssertError(t, errs, "TestPartial.SubSlice[0].Test", "Test", "required") |
|
|
|
AssertError(t, errs, "TestPartial.SubSlice[0].Test", "Test", "required") |
|
|
|
|
|
|
|
|
|
|
|
// reset struct in slice, and unset struct in slice in unset posistion
|
|
|
|
// reset struct in slice, and unset struct in slice in unset posistion
|
|
|
@ -439,7 +441,7 @@ func TestStructPartial(t *testing.T) { |
|
|
|
// testing for missing item by exception, yes it dives and fails
|
|
|
|
// testing for missing item by exception, yes it dives and fails
|
|
|
|
errs = validate.StructExcept(tPartial, p1...) |
|
|
|
errs = validate.StructExcept(tPartial, p1...) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
Equal(t, len(errs), 1) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 1) |
|
|
|
AssertError(t, errs, "TestPartial.SubSlice[1].Test", "Test", "required") |
|
|
|
AssertError(t, errs, "TestPartial.SubSlice[1].Test", "Test", "required") |
|
|
|
|
|
|
|
|
|
|
|
errs = validate.StructExcept(tPartial, p2...) |
|
|
|
errs = validate.StructExcept(tPartial, p2...) |
|
|
@ -1303,7 +1305,7 @@ func TestSQLValue2Validation(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
errs = validate.Struct(c) |
|
|
|
errs = validate.Struct(c) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
Equal(t, len(errs), 2) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 2) |
|
|
|
AssertError(t, errs, "CustomMadeUpStruct.MadeUp", "MadeUp", "required") |
|
|
|
AssertError(t, errs, "CustomMadeUpStruct.MadeUp", "MadeUp", "required") |
|
|
|
AssertError(t, errs, "CustomMadeUpStruct.OverriddenInt", "OverriddenInt", "gt") |
|
|
|
AssertError(t, errs, "CustomMadeUpStruct.OverriddenInt", "OverriddenInt", "gt") |
|
|
|
} |
|
|
|
} |
|
|
@ -1362,7 +1364,7 @@ func TestSQLValueValidation(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
errs = validate.Struct(c) |
|
|
|
errs = validate.Struct(c) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
Equal(t, len(errs), 2) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 2) |
|
|
|
AssertError(t, errs, "CustomMadeUpStruct.MadeUp", "MadeUp", "required") |
|
|
|
AssertError(t, errs, "CustomMadeUpStruct.MadeUp", "MadeUp", "required") |
|
|
|
AssertError(t, errs, "CustomMadeUpStruct.OverriddenInt", "OverriddenInt", "gt") |
|
|
|
AssertError(t, errs, "CustomMadeUpStruct.OverriddenInt", "OverriddenInt", "gt") |
|
|
|
} |
|
|
|
} |
|
|
@ -1393,7 +1395,7 @@ func TestMACValidation(t *testing.T) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
t.Fatalf("Index: %d mac failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d mac failed Error: %s", i, errs) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
val := errs[""] |
|
|
|
val := errs.(ValidationErrors)[""] |
|
|
|
if val.Tag != "mac" { |
|
|
|
if val.Tag != "mac" { |
|
|
|
t.Fatalf("Index: %d mac failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d mac failed Error: %s", i, errs) |
|
|
|
} |
|
|
|
} |
|
|
@ -1431,7 +1433,7 @@ func TestIPValidation(t *testing.T) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
t.Fatalf("Index: %d ip failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d ip failed Error: %s", i, errs) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
val := errs[""] |
|
|
|
val := errs.(ValidationErrors)[""] |
|
|
|
if val.Tag != "ip" { |
|
|
|
if val.Tag != "ip" { |
|
|
|
t.Fatalf("Index: %d ip failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d ip failed Error: %s", i, errs) |
|
|
|
} |
|
|
|
} |
|
|
@ -1469,7 +1471,7 @@ func TestIPv6Validation(t *testing.T) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
t.Fatalf("Index: %d ipv6 failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d ipv6 failed Error: %s", i, errs) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
val := errs[""] |
|
|
|
val := errs.(ValidationErrors)[""] |
|
|
|
if val.Tag != "ipv6" { |
|
|
|
if val.Tag != "ipv6" { |
|
|
|
t.Fatalf("Index: %d ipv6 failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d ipv6 failed Error: %s", i, errs) |
|
|
|
} |
|
|
|
} |
|
|
@ -1507,7 +1509,7 @@ func TestIPv4Validation(t *testing.T) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
t.Fatalf("Index: %d ipv4 failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d ipv4 failed Error: %s", i, errs) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
val := errs[""] |
|
|
|
val := errs.(ValidationErrors)[""] |
|
|
|
if val.Tag != "ipv4" { |
|
|
|
if val.Tag != "ipv4" { |
|
|
|
t.Fatalf("Index: %d ipv4 failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d ipv4 failed Error: %s", i, errs) |
|
|
|
} |
|
|
|
} |
|
|
@ -1664,7 +1666,7 @@ func TestInterfaceErrValidation(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
errs = validate.Struct(s) |
|
|
|
errs = validate.Struct(s) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
Equal(t, len(errs), 1) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 1) |
|
|
|
AssertError(t, errs, "ExternalCMD.Data", "Data", "required") |
|
|
|
AssertError(t, errs, "ExternalCMD.Data", "Data", "required") |
|
|
|
|
|
|
|
|
|
|
|
type ExternalCMD2 struct { |
|
|
|
type ExternalCMD2 struct { |
|
|
@ -1681,7 +1683,7 @@ func TestInterfaceErrValidation(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
errs = validate.Struct(s2) |
|
|
|
errs = validate.Struct(s2) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
Equal(t, len(errs), 1) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 1) |
|
|
|
AssertError(t, errs, "ExternalCMD2.Data", "Data", "len") |
|
|
|
AssertError(t, errs, "ExternalCMD2.Data", "Data", "len") |
|
|
|
|
|
|
|
|
|
|
|
s3 := &ExternalCMD2{ |
|
|
|
s3 := &ExternalCMD2{ |
|
|
@ -1692,7 +1694,7 @@ func TestInterfaceErrValidation(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
errs = validate.Struct(s3) |
|
|
|
errs = validate.Struct(s3) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
Equal(t, len(errs), 1) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 1) |
|
|
|
AssertError(t, errs, "ExternalCMD2.Data", "Data", "len") |
|
|
|
AssertError(t, errs, "ExternalCMD2.Data", "Data", "len") |
|
|
|
|
|
|
|
|
|
|
|
type Inner struct { |
|
|
|
type Inner struct { |
|
|
@ -1711,7 +1713,7 @@ func TestInterfaceErrValidation(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
errs = validate.Struct(s4) |
|
|
|
errs = validate.Struct(s4) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
Equal(t, len(errs), 1) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 1) |
|
|
|
AssertError(t, errs, "ExternalCMD.Data.Name", "Name", "required") |
|
|
|
AssertError(t, errs, "ExternalCMD.Data.Name", "Name", "required") |
|
|
|
|
|
|
|
|
|
|
|
type TestMapStructPtr struct { |
|
|
|
type TestMapStructPtr struct { |
|
|
@ -1726,7 +1728,7 @@ func TestInterfaceErrValidation(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
errs = validate.Struct(msp) |
|
|
|
errs = validate.Struct(msp) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
Equal(t, len(errs), 1) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 1) |
|
|
|
AssertError(t, errs, "TestMapStructPtr.Errs[3]", "Errs[3]", "len") |
|
|
|
AssertError(t, errs, "TestMapStructPtr.Errs[3]", "Errs[3]", "len") |
|
|
|
|
|
|
|
|
|
|
|
type TestMultiDimensionalStructs struct { |
|
|
|
type TestMultiDimensionalStructs struct { |
|
|
@ -1744,7 +1746,7 @@ func TestInterfaceErrValidation(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
errs = validate.Struct(tms) |
|
|
|
errs = validate.Struct(tms) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
Equal(t, len(errs), 4) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 4) |
|
|
|
AssertError(t, errs, "TestMultiDimensionalStructs.Errs[0][1].Name", "Name", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalStructs.Errs[0][1].Name", "Name", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalStructs.Errs[0][2].Name", "Name", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalStructs.Errs[0][2].Name", "Name", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalStructs.Errs[1][1].Name", "Name", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalStructs.Errs[1][1].Name", "Name", "required") |
|
|
@ -1766,7 +1768,7 @@ func TestInterfaceErrValidation(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
errs = validate.Struct(tmsp2) |
|
|
|
errs = validate.Struct(tmsp2) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
Equal(t, len(errs), 6) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 6) |
|
|
|
AssertError(t, errs, "TestMultiDimensionalStructsPtr2.Errs[0][1].Name", "Name", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalStructsPtr2.Errs[0][1].Name", "Name", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalStructsPtr2.Errs[0][2].Name", "Name", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalStructsPtr2.Errs[0][2].Name", "Name", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalStructsPtr2.Errs[1][1].Name", "Name", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalStructsPtr2.Errs[1][1].Name", "Name", "required") |
|
|
@ -1778,24 +1780,24 @@ func TestInterfaceErrValidation(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
errs = validate.Field(m, "len=3,dive,len=2") |
|
|
|
errs = validate.Field(m, "len=3,dive,len=2") |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
Equal(t, len(errs), 1) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 1) |
|
|
|
AssertError(t, errs, "[3]", "[3]", "len") |
|
|
|
AssertError(t, errs, "[3]", "[3]", "len") |
|
|
|
|
|
|
|
|
|
|
|
errs = validate.Field(m, "len=2,dive,required") |
|
|
|
errs = validate.Field(m, "len=2,dive,required") |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
Equal(t, len(errs), 1) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 1) |
|
|
|
AssertError(t, errs, "", "", "len") |
|
|
|
AssertError(t, errs, "", "", "len") |
|
|
|
|
|
|
|
|
|
|
|
arr := []interface{}{"ok", "", "ok"} |
|
|
|
arr := []interface{}{"ok", "", "ok"} |
|
|
|
|
|
|
|
|
|
|
|
errs = validate.Field(arr, "len=3,dive,len=2") |
|
|
|
errs = validate.Field(arr, "len=3,dive,len=2") |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
Equal(t, len(errs), 1) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 1) |
|
|
|
AssertError(t, errs, "[1]", "[1]", "len") |
|
|
|
AssertError(t, errs, "[1]", "[1]", "len") |
|
|
|
|
|
|
|
|
|
|
|
errs = validate.Field(arr, "len=2,dive,required") |
|
|
|
errs = validate.Field(arr, "len=2,dive,required") |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
Equal(t, len(errs), 1) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 1) |
|
|
|
AssertError(t, errs, "", "", "len") |
|
|
|
AssertError(t, errs, "", "", "len") |
|
|
|
|
|
|
|
|
|
|
|
type MyStruct struct { |
|
|
|
type MyStruct struct { |
|
|
@ -1822,12 +1824,12 @@ func TestMapDiveValidation(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
errs = validate.Field(m, "len=3,dive,required") |
|
|
|
errs = validate.Field(m, "len=3,dive,required") |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
Equal(t, len(errs), 1) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 1) |
|
|
|
AssertError(t, errs, "[3]", "[3]", "required") |
|
|
|
AssertError(t, errs, "[3]", "[3]", "required") |
|
|
|
|
|
|
|
|
|
|
|
errs = validate.Field(m, "len=2,dive,required") |
|
|
|
errs = validate.Field(m, "len=2,dive,required") |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
Equal(t, len(errs), 1) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 1) |
|
|
|
AssertError(t, errs, "", "", "len") |
|
|
|
AssertError(t, errs, "", "", "len") |
|
|
|
|
|
|
|
|
|
|
|
type Inner struct { |
|
|
|
type Inner struct { |
|
|
@ -1846,7 +1848,7 @@ func TestMapDiveValidation(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
errs = validate.Struct(ms) |
|
|
|
errs = validate.Struct(ms) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
Equal(t, len(errs), 1) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 1) |
|
|
|
AssertError(t, errs, "TestMapStruct.Errs[3].Name", "Name", "required") |
|
|
|
AssertError(t, errs, "TestMapStruct.Errs[3].Name", "Name", "required") |
|
|
|
|
|
|
|
|
|
|
|
// for full test coverage
|
|
|
|
// for full test coverage
|
|
|
@ -1867,7 +1869,7 @@ func TestMapDiveValidation(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
errs = validate.Struct(mt) |
|
|
|
errs = validate.Struct(mt) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
Equal(t, len(errs), 2) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 2) |
|
|
|
AssertError(t, errs, "TestMapTimeStruct.Errs[3]", "Errs[3]", "required") |
|
|
|
AssertError(t, errs, "TestMapTimeStruct.Errs[3]", "Errs[3]", "required") |
|
|
|
AssertError(t, errs, "TestMapTimeStruct.Errs[4]", "Errs[4]", "required") |
|
|
|
AssertError(t, errs, "TestMapTimeStruct.Errs[4]", "Errs[4]", "required") |
|
|
|
|
|
|
|
|
|
|
@ -1883,7 +1885,7 @@ func TestMapDiveValidation(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
errs = validate.Struct(msp) |
|
|
|
errs = validate.Struct(msp) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
Equal(t, len(errs), 1) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 1) |
|
|
|
AssertError(t, errs, "TestMapStructPtr.Errs[3]", "Errs[3]", "required") |
|
|
|
AssertError(t, errs, "TestMapStructPtr.Errs[3]", "Errs[3]", "required") |
|
|
|
|
|
|
|
|
|
|
|
type TestMapStructPtr2 struct { |
|
|
|
type TestMapStructPtr2 struct { |
|
|
@ -1906,12 +1908,12 @@ func TestArrayDiveValidation(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
errs := validate.Field(arr, "len=3,dive,required") |
|
|
|
errs := validate.Field(arr, "len=3,dive,required") |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
Equal(t, len(errs), 1) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 1) |
|
|
|
AssertError(t, errs, "[1]", "[1]", "required") |
|
|
|
AssertError(t, errs, "[1]", "[1]", "required") |
|
|
|
|
|
|
|
|
|
|
|
errs = validate.Field(arr, "len=2,dive,required") |
|
|
|
errs = validate.Field(arr, "len=2,dive,required") |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
Equal(t, len(errs), 1) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 1) |
|
|
|
AssertError(t, errs, "", "", "len") |
|
|
|
AssertError(t, errs, "", "", "len") |
|
|
|
|
|
|
|
|
|
|
|
type BadDive struct { |
|
|
|
type BadDive struct { |
|
|
@ -1934,7 +1936,7 @@ func TestArrayDiveValidation(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
errs = validate.Struct(test) |
|
|
|
errs = validate.Struct(test) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
Equal(t, len(errs), 1) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 1) |
|
|
|
AssertError(t, errs, "Test.Errs[1]", "Errs[1]", "required") |
|
|
|
AssertError(t, errs, "Test.Errs[1]", "Errs[1]", "required") |
|
|
|
|
|
|
|
|
|
|
|
test = &Test{ |
|
|
|
test = &Test{ |
|
|
@ -1943,7 +1945,7 @@ func TestArrayDiveValidation(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
errs = validate.Struct(test) |
|
|
|
errs = validate.Struct(test) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
Equal(t, len(errs), 1) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 1) |
|
|
|
AssertError(t, errs, "Test.Errs[2]", "Errs[2]", "required") |
|
|
|
AssertError(t, errs, "Test.Errs[2]", "Errs[2]", "required") |
|
|
|
|
|
|
|
|
|
|
|
type TestMultiDimensional struct { |
|
|
|
type TestMultiDimensional struct { |
|
|
@ -1961,7 +1963,7 @@ func TestArrayDiveValidation(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
errs = validate.Struct(tm) |
|
|
|
errs = validate.Struct(tm) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
Equal(t, len(errs), 4) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 4) |
|
|
|
AssertError(t, errs, "TestMultiDimensional.Errs[0][1]", "Errs[0][1]", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensional.Errs[0][1]", "Errs[0][1]", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensional.Errs[0][2]", "Errs[0][2]", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensional.Errs[0][2]", "Errs[0][2]", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensional.Errs[1][1]", "Errs[1][1]", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensional.Errs[1][1]", "Errs[1][1]", "required") |
|
|
@ -1986,7 +1988,7 @@ func TestArrayDiveValidation(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
errs = validate.Struct(tms) |
|
|
|
errs = validate.Struct(tms) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
Equal(t, len(errs), 4) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 4) |
|
|
|
AssertError(t, errs, "TestMultiDimensionalStructs.Errs[0][1].Name", "Name", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalStructs.Errs[0][1].Name", "Name", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalStructs.Errs[0][2].Name", "Name", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalStructs.Errs[0][2].Name", "Name", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalStructs.Errs[1][1].Name", "Name", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalStructs.Errs[1][1].Name", "Name", "required") |
|
|
@ -2008,7 +2010,7 @@ func TestArrayDiveValidation(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
errs = validate.Struct(tmsp) |
|
|
|
errs = validate.Struct(tmsp) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
Equal(t, len(errs), 5) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 5) |
|
|
|
AssertError(t, errs, "TestMultiDimensionalStructsPtr.Errs[0][1].Name", "Name", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalStructsPtr.Errs[0][1].Name", "Name", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalStructsPtr.Errs[0][2].Name", "Name", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalStructsPtr.Errs[0][2].Name", "Name", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalStructsPtr.Errs[1][1].Name", "Name", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalStructsPtr.Errs[1][1].Name", "Name", "required") |
|
|
@ -2035,7 +2037,7 @@ func TestArrayDiveValidation(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
errs = validate.Struct(tmsp2) |
|
|
|
errs = validate.Struct(tmsp2) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
Equal(t, len(errs), 6) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 6) |
|
|
|
AssertError(t, errs, "TestMultiDimensionalStructsPtr2.Errs[0][1].Name", "Name", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalStructsPtr2.Errs[0][1].Name", "Name", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalStructsPtr2.Errs[0][2].Name", "Name", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalStructsPtr2.Errs[0][2].Name", "Name", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalStructsPtr2.Errs[1][1].Name", "Name", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalStructsPtr2.Errs[1][1].Name", "Name", "required") |
|
|
@ -2059,7 +2061,7 @@ func TestArrayDiveValidation(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
errs = validate.Struct(tmsp3) |
|
|
|
errs = validate.Struct(tmsp3) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
Equal(t, len(errs), 5) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 5) |
|
|
|
AssertError(t, errs, "TestMultiDimensionalStructsPtr3.Errs[0][1].Name", "Name", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalStructsPtr3.Errs[0][1].Name", "Name", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalStructsPtr3.Errs[0][2].Name", "Name", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalStructsPtr3.Errs[0][2].Name", "Name", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalStructsPtr3.Errs[1][1].Name", "Name", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalStructsPtr3.Errs[1][1].Name", "Name", "required") |
|
|
@ -2086,7 +2088,7 @@ func TestArrayDiveValidation(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
errs = validate.Struct(tmtp3) |
|
|
|
errs = validate.Struct(tmtp3) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
Equal(t, len(errs), 3) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 3) |
|
|
|
AssertError(t, errs, "TestMultiDimensionalTimeTime.Errs[1][2]", "Errs[1][2]", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalTimeTime.Errs[1][2]", "Errs[1][2]", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalTimeTime.Errs[2][1]", "Errs[2][1]", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalTimeTime.Errs[2][1]", "Errs[2][1]", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalTimeTime.Errs[2][2]", "Errs[2][2]", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalTimeTime.Errs[2][2]", "Errs[2][2]", "required") |
|
|
@ -2111,7 +2113,7 @@ func TestArrayDiveValidation(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
errs = validate.Struct(tmtp) |
|
|
|
errs = validate.Struct(tmtp) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
Equal(t, len(errs), 3) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 3) |
|
|
|
AssertError(t, errs, "TestMultiDimensionalTimeTime2.Errs[1][2]", "Errs[1][2]", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalTimeTime2.Errs[1][2]", "Errs[1][2]", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalTimeTime2.Errs[2][1]", "Errs[2][1]", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalTimeTime2.Errs[2][1]", "Errs[2][1]", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalTimeTime2.Errs[2][2]", "Errs[2][2]", "required") |
|
|
|
AssertError(t, errs, "TestMultiDimensionalTimeTime2.Errs[2][2]", "Errs[2][2]", "required") |
|
|
@ -2234,7 +2236,7 @@ func TestSSNValidation(t *testing.T) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
t.Fatalf("Index: %d SSN failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d SSN failed Error: %s", i, errs) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
val := errs[""] |
|
|
|
val := errs.(ValidationErrors)[""] |
|
|
|
if val.Tag != "ssn" { |
|
|
|
if val.Tag != "ssn" { |
|
|
|
t.Fatalf("Index: %d Latitude failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d Latitude failed Error: %s", i, errs) |
|
|
|
} |
|
|
|
} |
|
|
@ -2268,7 +2270,7 @@ func TestLongitudeValidation(t *testing.T) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
t.Fatalf("Index: %d Longitude failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d Longitude failed Error: %s", i, errs) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
val := errs[""] |
|
|
|
val := errs.(ValidationErrors)[""] |
|
|
|
if val.Tag != "longitude" { |
|
|
|
if val.Tag != "longitude" { |
|
|
|
t.Fatalf("Index: %d Latitude failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d Latitude failed Error: %s", i, errs) |
|
|
|
} |
|
|
|
} |
|
|
@ -2302,7 +2304,7 @@ func TestLatitudeValidation(t *testing.T) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
t.Fatalf("Index: %d Latitude failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d Latitude failed Error: %s", i, errs) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
val := errs[""] |
|
|
|
val := errs.(ValidationErrors)[""] |
|
|
|
if val.Tag != "latitude" { |
|
|
|
if val.Tag != "latitude" { |
|
|
|
t.Fatalf("Index: %d Latitude failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d Latitude failed Error: %s", i, errs) |
|
|
|
} |
|
|
|
} |
|
|
@ -2342,7 +2344,7 @@ func TestDataURIValidation(t *testing.T) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
t.Fatalf("Index: %d DataURI failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d DataURI failed Error: %s", i, errs) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
val := errs[""] |
|
|
|
val := errs.(ValidationErrors)[""] |
|
|
|
if val.Tag != "datauri" { |
|
|
|
if val.Tag != "datauri" { |
|
|
|
t.Fatalf("Index: %d DataURI failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d DataURI failed Error: %s", i, errs) |
|
|
|
} |
|
|
|
} |
|
|
@ -2380,7 +2382,7 @@ func TestMultibyteValidation(t *testing.T) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
t.Fatalf("Index: %d Multibyte failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d Multibyte failed Error: %s", i, errs) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
val := errs[""] |
|
|
|
val := errs.(ValidationErrors)[""] |
|
|
|
if val.Tag != "multibyte" { |
|
|
|
if val.Tag != "multibyte" { |
|
|
|
t.Fatalf("Index: %d Multibyte failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d Multibyte failed Error: %s", i, errs) |
|
|
|
} |
|
|
|
} |
|
|
@ -2419,7 +2421,7 @@ func TestPrintableASCIIValidation(t *testing.T) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
t.Fatalf("Index: %d Printable ASCII failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d Printable ASCII failed Error: %s", i, errs) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
val := errs[""] |
|
|
|
val := errs.(ValidationErrors)[""] |
|
|
|
if val.Tag != "printascii" { |
|
|
|
if val.Tag != "printascii" { |
|
|
|
t.Fatalf("Index: %d Printable ASCII failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d Printable ASCII failed Error: %s", i, errs) |
|
|
|
} |
|
|
|
} |
|
|
@ -2457,7 +2459,7 @@ func TestASCIIValidation(t *testing.T) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
t.Fatalf("Index: %d ASCII failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d ASCII failed Error: %s", i, errs) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
val := errs[""] |
|
|
|
val := errs.(ValidationErrors)[""] |
|
|
|
if val.Tag != "ascii" { |
|
|
|
if val.Tag != "ascii" { |
|
|
|
t.Fatalf("Index: %d ASCII failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d ASCII failed Error: %s", i, errs) |
|
|
|
} |
|
|
|
} |
|
|
@ -2492,7 +2494,7 @@ func TestUUID5Validation(t *testing.T) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
t.Fatalf("Index: %d UUID5 failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d UUID5 failed Error: %s", i, errs) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
val := errs[""] |
|
|
|
val := errs.(ValidationErrors)[""] |
|
|
|
if val.Tag != "uuid5" { |
|
|
|
if val.Tag != "uuid5" { |
|
|
|
t.Fatalf("Index: %d UUID5 failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d UUID5 failed Error: %s", i, errs) |
|
|
|
} |
|
|
|
} |
|
|
@ -2526,7 +2528,7 @@ func TestUUID4Validation(t *testing.T) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
t.Fatalf("Index: %d UUID4 failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d UUID4 failed Error: %s", i, errs) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
val := errs[""] |
|
|
|
val := errs.(ValidationErrors)[""] |
|
|
|
if val.Tag != "uuid4" { |
|
|
|
if val.Tag != "uuid4" { |
|
|
|
t.Fatalf("Index: %d UUID4 failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d UUID4 failed Error: %s", i, errs) |
|
|
|
} |
|
|
|
} |
|
|
@ -2559,7 +2561,7 @@ func TestUUID3Validation(t *testing.T) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
t.Fatalf("Index: %d UUID3 failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d UUID3 failed Error: %s", i, errs) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
val := errs[""] |
|
|
|
val := errs.(ValidationErrors)[""] |
|
|
|
if val.Tag != "uuid3" { |
|
|
|
if val.Tag != "uuid3" { |
|
|
|
t.Fatalf("Index: %d UUID3 failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d UUID3 failed Error: %s", i, errs) |
|
|
|
} |
|
|
|
} |
|
|
@ -2595,7 +2597,7 @@ func TestUUIDValidation(t *testing.T) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
t.Fatalf("Index: %d UUID failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d UUID failed Error: %s", i, errs) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
val := errs[""] |
|
|
|
val := errs.(ValidationErrors)[""] |
|
|
|
if val.Tag != "uuid" { |
|
|
|
if val.Tag != "uuid" { |
|
|
|
t.Fatalf("Index: %d UUID failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d UUID failed Error: %s", i, errs) |
|
|
|
} |
|
|
|
} |
|
|
@ -2633,7 +2635,7 @@ func TestISBNValidation(t *testing.T) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
t.Fatalf("Index: %d ISBN failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d ISBN failed Error: %s", i, errs) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
val := errs[""] |
|
|
|
val := errs.(ValidationErrors)[""] |
|
|
|
if val.Tag != "isbn" { |
|
|
|
if val.Tag != "isbn" { |
|
|
|
t.Fatalf("Index: %d ISBN failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d ISBN failed Error: %s", i, errs) |
|
|
|
} |
|
|
|
} |
|
|
@ -2670,7 +2672,7 @@ func TestISBN13Validation(t *testing.T) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
t.Fatalf("Index: %d ISBN13 failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d ISBN13 failed Error: %s", i, errs) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
val := errs[""] |
|
|
|
val := errs.(ValidationErrors)[""] |
|
|
|
if val.Tag != "isbn13" { |
|
|
|
if val.Tag != "isbn13" { |
|
|
|
t.Fatalf("Index: %d ISBN13 failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d ISBN13 failed Error: %s", i, errs) |
|
|
|
} |
|
|
|
} |
|
|
@ -2708,7 +2710,7 @@ func TestISBN10Validation(t *testing.T) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
t.Fatalf("Index: %d ISBN10 failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d ISBN10 failed Error: %s", i, errs) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
val := errs[""] |
|
|
|
val := errs.(ValidationErrors)[""] |
|
|
|
if val.Tag != "isbn10" { |
|
|
|
if val.Tag != "isbn10" { |
|
|
|
t.Fatalf("Index: %d ISBN10 failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d ISBN10 failed Error: %s", i, errs) |
|
|
|
} |
|
|
|
} |
|
|
@ -4177,7 +4179,7 @@ func TestUrl(t *testing.T) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
t.Fatalf("Index: %d URL failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d URL failed Error: %s", i, errs) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
val := errs[""] |
|
|
|
val := errs.(ValidationErrors)[""] |
|
|
|
if val.Tag != "url" { |
|
|
|
if val.Tag != "url" { |
|
|
|
t.Fatalf("Index: %d URL failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d URL failed Error: %s", i, errs) |
|
|
|
} |
|
|
|
} |
|
|
@ -4241,7 +4243,7 @@ func TestUri(t *testing.T) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
if IsEqual(errs, nil) { |
|
|
|
t.Fatalf("Index: %d URI failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d URI failed Error: %s", i, errs) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
val := errs[""] |
|
|
|
val := errs.(ValidationErrors)[""] |
|
|
|
if val.Tag != "uri" { |
|
|
|
if val.Tag != "uri" { |
|
|
|
t.Fatalf("Index: %d URI failed Error: %s", i, errs) |
|
|
|
t.Fatalf("Index: %d URI failed Error: %s", i, errs) |
|
|
|
} |
|
|
|
} |
|
|
@ -4707,7 +4709,7 @@ func TestStructStringValidation(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
// Assert Top Level
|
|
|
|
// Assert Top Level
|
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
Equal(t, len(errs), 13) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 13) |
|
|
|
|
|
|
|
|
|
|
|
// Assert Fields
|
|
|
|
// Assert Fields
|
|
|
|
AssertError(t, errs, "TestString.Required", "Required", "required") |
|
|
|
AssertError(t, errs, "TestString.Required", "Required", "required") |
|
|
@ -4762,7 +4764,7 @@ func TestStructInt32Validation(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
// Assert Top Level
|
|
|
|
// Assert Top Level
|
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
Equal(t, len(errs), 10) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 10) |
|
|
|
|
|
|
|
|
|
|
|
// Assert Fields
|
|
|
|
// Assert Fields
|
|
|
|
AssertError(t, errs, "TestInt32.Required", "Required", "required") |
|
|
|
AssertError(t, errs, "TestInt32.Required", "Required", "required") |
|
|
@ -4804,7 +4806,7 @@ func TestStructUint64Validation(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
// Assert Top Level
|
|
|
|
// Assert Top Level
|
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
Equal(t, len(errs), 6) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 6) |
|
|
|
|
|
|
|
|
|
|
|
// Assert Fields
|
|
|
|
// Assert Fields
|
|
|
|
AssertError(t, errs, "TestUint64.Required", "Required", "required") |
|
|
|
AssertError(t, errs, "TestUint64.Required", "Required", "required") |
|
|
@ -4842,7 +4844,7 @@ func TestStructFloat64Validation(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
// Assert Top Level
|
|
|
|
// Assert Top Level
|
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
Equal(t, len(errs), 6) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 6) |
|
|
|
|
|
|
|
|
|
|
|
// Assert Fields
|
|
|
|
// Assert Fields
|
|
|
|
AssertError(t, errs, "TestFloat64.Required", "Required", "required") |
|
|
|
AssertError(t, errs, "TestFloat64.Required", "Required", "required") |
|
|
@ -4878,7 +4880,7 @@ func TestStructSliceValidation(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
errs = validate.Struct(tFail) |
|
|
|
errs = validate.Struct(tFail) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
NotEqual(t, errs, nil) |
|
|
|
Equal(t, len(errs), 6) |
|
|
|
Equal(t, len(errs.(ValidationErrors)), 6) |
|
|
|
|
|
|
|
|
|
|
|
// Assert Field Errors
|
|
|
|
// Assert Field Errors
|
|
|
|
AssertError(t, errs, "TestSlice.Required", "Required", "required") |
|
|
|
AssertError(t, errs, "TestSlice.Required", "Required", "required") |
|
|
|