@@ -746,11 +746,9 @@ func TestStructPartial(t *testing.T) {
746
746
747
747
SubSlice : []* SubTest {
748
748
{
749
-
750
749
Test : "Required" ,
751
750
},
752
751
{
753
-
754
752
Test : "Required" ,
755
753
},
756
754
},
@@ -4002,7 +4000,6 @@ func TestUUID5Validation(t *testing.T) {
4002
4000
param string
4003
4001
expected bool
4004
4002
}{
4005
-
4006
4003
{"" , false },
4007
4004
{"xxxa987fbc9-4bed-3078-cf07-9141ba07c9f3" , false },
4008
4005
{"9c858901-8a57-4791-81fe-4c455b099bc9" , false },
@@ -4119,8 +4116,10 @@ func (u uuidAlias) String() string {
4119
4116
return "This is a UUID " + string (u )
4120
4117
}
4121
4118
4122
- var _ fmt.Stringer = uuidTestType {}
4123
- var _ fmt.Stringer = uuidAlias ("" )
4119
+ var (
4120
+ _ fmt.Stringer = uuidTestType {}
4121
+ _ fmt.Stringer = uuidAlias ("" )
4122
+ )
4124
4123
4125
4124
func TestUUIDValidation (t * testing.T ) {
4126
4125
tests := []struct {
@@ -4190,7 +4189,6 @@ func TestUUID5RFC4122Validation(t *testing.T) {
4190
4189
param string
4191
4190
expected bool
4192
4191
}{
4193
-
4194
4192
{"" , false },
4195
4193
{"xxxa987Fbc9-4bed-3078-cf07-9141ba07c9f3" , false },
4196
4194
{"9c858901-8a57-4791-81Fe-4c455b099bc9" , false },
@@ -8903,6 +8901,7 @@ func TestNumeric(t *testing.T) {
8903
8901
errs = validate .Var (i , "numeric" )
8904
8902
Equal (t , errs , nil )
8905
8903
}
8904
+
8906
8905
func TestBoolean (t * testing.T ) {
8907
8906
validate := New ()
8908
8907
@@ -9628,11 +9627,9 @@ func TestStructFiltered(t *testing.T) {
9628
9627
9629
9628
SubSlice : []* SubTest {
9630
9629
{
9631
-
9632
9630
Test : "Required" ,
9633
9631
},
9634
9632
{
9635
-
9636
9633
Test : "Required" ,
9637
9634
},
9638
9635
},
@@ -12080,7 +12077,7 @@ func TestExcludedIf(t *testing.T) {
12080
12077
12081
12078
test11 := struct {
12082
12079
Field1 bool
12083
- Field2 * string `validate:"excluded_if=Field1 false"`
12080
+ Field2 * string `validate:"excluded_if=Field1 false"`
12084
12081
}{
12085
12082
Field1 : false ,
12086
12083
Field2 : nil ,
@@ -12788,7 +12785,7 @@ func TestIsIso3166AlphaNumericEUValidation(t *testing.T) {
12788
12785
value interface {}
12789
12786
expected bool
12790
12787
}{
12791
- {752 , true }, //Sweden
12788
+ {752 , true }, // Sweden
12792
12789
{"752" , true },
12793
12790
{826 , false }, // UK
12794
12791
{"826" , false },
@@ -13185,7 +13182,6 @@ func TestSemverFormatValidation(t *testing.T) {
13185
13182
}
13186
13183
13187
13184
func TestCveFormatValidation (t * testing.T ) {
13188
-
13189
13185
tests := []struct {
13190
13186
value string `validate:"cve"`
13191
13187
tag string
@@ -13384,7 +13380,6 @@ func TestPostCodeByIso3166Alpha2Field_InvalidKind(t *testing.T) {
13384
13380
}
13385
13381
13386
13382
func TestValidate_ValidateMapCtx (t * testing.T ) {
13387
-
13388
13383
type args struct {
13389
13384
data map [string ]interface {}
13390
13385
rules map [string ]interface {}
@@ -13509,6 +13504,7 @@ func TestMongoDBObjectIDFormatValidation(t *testing.T) {
13509
13504
}
13510
13505
}
13511
13506
}
13507
+
13512
13508
func TestMongoDBConnectionStringFormatValidation (t * testing.T ) {
13513
13509
tests := []struct {
13514
13510
value string `validate:"mongodb_connection_string"`
@@ -13919,7 +13915,7 @@ func TestNestedStructValidation(t *testing.T) {
13919
13915
},
13920
13916
}
13921
13917
13922
- var evaluateTest = func (tt test , errs error ) {
13918
+ evaluateTest : = func (tt test , errs error ) {
13923
13919
if tt .err != (testErr {}) && errs != nil {
13924
13920
Equal (t , len (errs .(ValidationErrors )), 1 )
13925
13921
@@ -14075,6 +14071,36 @@ func TestOmitZero(t *testing.T) {
14075
14071
})
14076
14072
}
14077
14073
14074
+ func TestEINStringValidation (t * testing.T ) {
14075
+ tests := []struct {
14076
+ value string `validate:"ein"`
14077
+ expected bool
14078
+ }{
14079
+ {"01-2564282" , true },
14080
+ {"25-4573894" , true },
14081
+ {"63-236" , false },
14082
+ {"3-5738294" , false },
14083
+ {"4235-48" , false },
14084
+ {"0.-47829" , false },
14085
+ {"23-" , false },
14086
+ }
14087
+ validate := New ()
14088
+
14089
+ for i , test := range tests {
14090
+ errs := validate .Var (test .value , "ein" )
14091
+
14092
+ if test .expected {
14093
+ if ! IsEqual (errs , nil ) {
14094
+ t .Fatalf ("Index: %d ein failed Error: %s" , i , errs )
14095
+ }
14096
+ } else {
14097
+ if IsEqual (errs , nil ) {
14098
+ t .Fatalf ("Index: %d ein failed Error: %s" , i , errs )
14099
+ }
14100
+ }
14101
+ }
14102
+ }
14103
+
14078
14104
func TestPrivateFieldsStruct (t * testing.T ) {
14079
14105
type tc struct {
14080
14106
stct interface {}
0 commit comments