@@ -1827,49 +1827,75 @@ public function testRuleWithAsteriskToMultiDimensionalArray(): void
18271827 );
18281828 }
18291829
1830- public function testRuleWithMultipleAsterisk (): void
1830+ /**
1831+ * @see https://github.com/codeigniter4/CodeIgniter4/issues/9219
1832+ */
1833+ #[DataProvider('provideMultipleAsterisk ' )]
1834+ public function testRuleWithMultipleAsterisk (array $ data = [], array $ rules = [], bool $ expectedCheck = false , array $ expectedData = []): void
18311835 {
1832- $ data = [
1833- 'id ' => 1 ,
1834- 'dates ' => [
1835- 23 => [
1836- 45 => 'Its Mee! ' ,
1836+ $ this ->validation ->setRules ($ rules );
1837+
1838+ $ this ->assertSame ($ expectedCheck , $ this ->validation ->run ($ data ));
1839+ $ this ->assertSame ($ expectedData , $ this ->validation ->getValidated ());
1840+ }
1841+
1842+ public static function provideMultipleAsterisk (): iterable
1843+ {
1844+ yield 'success ' => [
1845+ [
1846+ 'dates ' => [
1847+ 23 => [
1848+ 45 => 'Its Mee! ' ,
1849+ ],
1850+ ],
1851+ 'foo ' => [
1852+ 'bar ' => [
1853+ 'data ' => [
1854+ 'name ' => 'John Doe ' ,
1855+ 'age ' => 29 ,
1856+ 'location ' => 'Indonesia ' ,
1857+ ],
1858+ ],
18371859 ],
18381860 ],
1839- 'foo ' => [
1840- 'bar ' => [
1841- 'data ' => [
1842- 'name ' => 'John Doe ' ,
1843- 'age ' => 29 ,
1844- 'location ' => 'Indonesia ' ,
1861+ [
1862+ 'dates.*.* ' => 'required ' ,
1863+ 'foo.*.*.* ' => 'required ' ,
1864+ ],
1865+ true ,
1866+ [
1867+ 'dates ' => [
1868+ 23 => [
1869+ 45 => 'Its Mee! ' ,
1870+ ],
1871+ ],
1872+ 'foo ' => [
1873+ 'bar ' => [
1874+ 'data ' => [
1875+ 'name ' => 'John Doe ' ,
1876+ 'age ' => 29 ,
1877+ 'location ' => 'Indonesia ' ,
1878+ ],
18451879 ],
18461880 ],
18471881 ],
18481882 ];
18491883
1850- $ this ->validation ->setRules ([
1851- 'id ' => 'required|numeric ' ,
1852- 'dates.*.* ' => 'required ' ,
1853- 'foo.*.*.* ' => 'required ' ,
1854- ]);
1855-
1856- $ this ->assertTrue ($ this ->validation ->run ($ data ));
1857- $ this ->assertSame ([
1858- 'id ' => 1 ,
1859- 'dates ' => [
1860- 23 => [
1861- 45 => 'Its Mee! ' ,
1862- ],
1863- ],
1864- 'foo ' => [
1865- 'bar ' => [
1866- 'data ' => [
1867- 'name ' => 'John Doe ' ,
1868- 'age ' => 29 ,
1869- 'location ' => 'Indonesia ' ,
1884+ yield 'failed ' => [
1885+ [
1886+ 'foo ' => [
1887+ 'bar ' => [
1888+ 'data ' => [
1889+ 'name ' => '' ,
1890+ 'age ' => 29 ,
1891+ 'location ' => 'Indonesia ' ,
1892+ ],
18701893 ],
18711894 ],
18721895 ],
1873- ], $ this ->validation ->getValidated ());
1896+ ['foo.*.*.* ' => 'required ' ],
1897+ false ,
1898+ [],
1899+ ];
18741900 }
18751901}
0 commit comments