33namespace Inhere \ValidateTest ;
44
55use Inhere \Validate \RuleValidation ;
6+ use Inhere \Validate \RV ;
67use Inhere \Validate \Validation ;
78use PHPUnit \Framework \TestCase ;
89use PHPUnit \Runner \Version ;
@@ -610,6 +611,9 @@ public function testValidatorAlias(): void
610611 $ this ->assertEquals ('list val must be an array ' , $ v ->lastError ());
611612 }
612613
614+ /**
615+ * @link https://github.com/inhere/php-validate/issues/13
616+ */
613617 public function testIssue13 (): void
614618 {
615619 $ rule = [
@@ -619,7 +623,9 @@ public function testIssue13(): void
619623
620624 $ v = Validation::check ([
621625 'goods_id ' => [
622- 1144181460261978556 , 114418146 , 1144
626+ // 1144181460261978556,
627+ 114418146 ,
628+ 1144
623629 ]
624630 ], $ rule );
625631
@@ -647,4 +653,43 @@ public function testIssue13(): void
647653 $ this ->assertFalse ($ v ->isOk ());
648654 $ this ->assertSame ('商品分类id必须是一串数字 ' , $ v ->firstError ());
649655 }
656+
657+ /**
658+ * @link https://github.com/inhere/php-validate/issues/21
659+ */
660+ public function tIssues21 (): void
661+ {
662+ $ rs = [
663+ ['users.*.id ' , 'required ' ],
664+ ['users.*.id ' , 'each ' , 'required ' ],
665+ // ['users.*.id', 'each', 'string']
666+ ];
667+
668+ $ v = RV ::check ([
669+ 'users ' => [
670+ ['name ' => 'n1 ' ],
671+ ['name ' => 'n1 ' ],
672+ ],
673+ ], $ rs );
674+
675+ $ this ->assertFalse ($ v ->isOk ());
676+ $ this ->assertSame ('parameter users.*.id is required! ' , $ v ->firstError ());
677+
678+ $ v = RV ::check ([
679+ 'users ' => [
680+ ['name ' => 'n1 ' ],
681+ ['id ' => 2 , 'name ' => 'n1 ' ],
682+ ],
683+ ], $ rs );
684+
685+ $ this ->assertFalse ($ v ->isOk ());
686+ $ this ->assertSame ('' , $ v ->firstError ());
687+
688+ $ v = RV ::check ([
689+ 'users ' => [
690+ ['id ' => 1 , 'name ' => 'n1 ' ],
691+ ['id ' => 2 , 'name ' => 'n1 ' ],
692+ ],
693+ ], $ rs );
694+ }
650695}
0 commit comments