@@ -558,19 +558,37 @@ func Test_CSSColor(t *testing.T) {
558558
559559func Test_Digits (t * testing.T ) {
560560 type user struct {
561- Zip string `json:"zip"`
562- Level string `json:"level"`
561+ Zip string `json:"zip"`
562+ Level string `json:"level"`
563+ EpochInt int `json:"epoch_int"`
564+ EpochInt64 int64 `json:"epoch_int_64"`
565+ EpochFloat32 float32 `json:"epoch_float_32"`
566+ EpochFloat64 float64 `json:"epoch_float_64"`
567+ EpochString string `json:"epoch_string"`
563568 }
564569
565- postUser := user {Zip : "8322" , Level : "10" }
570+ postUser := user {
571+ Zip : "8322" ,
572+ Level : "10" ,
573+ EpochInt : 1541689 ,
574+ EpochInt64 : 15416890380008 ,
575+ EpochFloat32 : 15416890380008 ,
576+ EpochFloat64 : 15416890380008 ,
577+ EpochString : "15416890380008" ,
578+ }
566579 var userObj user
567580
568581 body , _ := json .Marshal (postUser )
569582 req , _ := http .NewRequest ("POST" , "http://www.example.com" , bytes .NewReader (body ))
570583
571584 rules := MapData {
572- "zip" : []string {"digits:5" },
573- "level" : []string {"digits:1" },
585+ "zip" : []string {"digits:5" },
586+ "level" : []string {"digits:1" },
587+ "epoch_int" : []string {"digits:13" },
588+ "epoch_int_64" : []string {"digits:13" },
589+ "epoch_float_32" : []string {"digits:13" },
590+ "epoch_float_64" : []string {"digits:13" },
591+ "epoch_string" : []string {"digits:13" },
574592 }
575593
576594 opts := Options {
@@ -581,7 +599,8 @@ func Test_Digits(t *testing.T) {
581599
582600 vd := New (opts )
583601 validationErr := vd .ValidateJSON ()
584- if len (validationErr ) != 2 {
602+ if len (validationErr ) != 7 {
603+ t .Log (validationErr )
585604 t .Error ("Digits validation failed!" )
586605 }
587606}
0 commit comments