|
|
@ -11053,12 +11053,15 @@ func TestIsIso3166Alpha3Validation(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
func TestIsIso3166AlphaNumericValidation(t *testing.T) { |
|
|
|
func TestIsIso3166AlphaNumericValidation(t *testing.T) { |
|
|
|
tests := []struct { |
|
|
|
tests := []struct { |
|
|
|
value int |
|
|
|
value interface{} |
|
|
|
expected bool |
|
|
|
expected bool |
|
|
|
}{ |
|
|
|
}{ |
|
|
|
{248, true}, |
|
|
|
{248, true}, |
|
|
|
|
|
|
|
{"248", true}, |
|
|
|
{0, false}, |
|
|
|
{0, false}, |
|
|
|
{1, false}, |
|
|
|
{1, false}, |
|
|
|
|
|
|
|
{"1", false}, |
|
|
|
|
|
|
|
{"invalid_int", false}, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
validate := New() |
|
|
|
validate := New() |
|
|
@ -11079,8 +11082,41 @@ func TestIsIso3166AlphaNumericValidation(t *testing.T) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
PanicMatches(t, func() { |
|
|
|
PanicMatches(t, func() { |
|
|
|
_ = validate.Var("1", "iso3166_1_alpha_numeric") |
|
|
|
_ = validate.Var([]string{"1"}, "iso3166_1_alpha_numeric") |
|
|
|
}, "Bad field type string") |
|
|
|
}, "Bad field type []string") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func TestCountryCodeValidation(t *testing.T) { |
|
|
|
|
|
|
|
tests := []struct { |
|
|
|
|
|
|
|
value interface{} |
|
|
|
|
|
|
|
expected bool |
|
|
|
|
|
|
|
}{ |
|
|
|
|
|
|
|
{248, true}, |
|
|
|
|
|
|
|
{0, false}, |
|
|
|
|
|
|
|
{1, false}, |
|
|
|
|
|
|
|
{"POL", true}, |
|
|
|
|
|
|
|
{"NO", true}, |
|
|
|
|
|
|
|
{"248", true}, |
|
|
|
|
|
|
|
{"1", false}, |
|
|
|
|
|
|
|
{"0", false}, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
validate := New() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for i, test := range tests { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
errs := validate.Var(test.value, "country_code") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if test.expected { |
|
|
|
|
|
|
|
if !IsEqual(errs, nil) { |
|
|
|
|
|
|
|
t.Fatalf("Index: %d country_code failed Error: %s", i, errs) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
if IsEqual(errs, nil) { |
|
|
|
|
|
|
|
t.Fatalf("Index: %d country_code failed Error: %s", i, errs) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestIsIso4217Validation(t *testing.T) { |
|
|
|
func TestIsIso4217Validation(t *testing.T) { |
|
|
|