@@ -86,6 +86,48 @@ public function testRegexMatchFalse(): void
8686 $ this ->assertFalse ($ this ->validation ->run ($ data ));
8787 }
8888
89+ /**
90+ * @see https://github.com/codeigniter4/CodeIgniter4/issues/9596
91+ */
92+ public function testRegexMatchWithArrayData (): void
93+ {
94+ $ data = [
95+ ['uid ' => '2025/06/000001 ' ],
96+ ['uid ' => '2025/06/000002 ' ],
97+ ['uid ' => '2025/06/000003 ' ],
98+ ['uid ' => '2025/06/000004 ' ],
99+ ['uid ' => '2025/06/000005 ' ],
100+ ];
101+
102+ $ this ->validation ->setRules ([
103+ '*.uid ' => 'regex_match[/^(\d{4})\/(0[1-9]|1[0-2])\/\d{6}$/] ' ,
104+ ]);
105+
106+ $ this ->assertTrue ($ this ->validation ->run ($ data ));
107+ }
108+
109+ public function testRegexMatchWithPlaceholder (): void
110+ {
111+ $ data = [
112+ 'code ' => 'ABC1234 ' ,
113+ 'phone ' => '1234567890 ' ,
114+ 'prefix ' => 'ABC ' ,
115+ 'min_digits ' => 10 ,
116+ 'max_digits ' => 15 ,
117+ ];
118+
119+ $ this ->validation ->setRules ([
120+ 'prefix ' => 'required|string ' ,
121+ 'min_digits ' => 'required|integer ' ,
122+ 'max_digits ' => 'required|integer ' ,
123+ 'code ' => 'required|regex_match[/^{{prefix}}\d{4}$/] ' ,
124+ 'phone ' => 'required|regex_match[/^\d{{{min_digits}},{{max_digits}}}$/] ' ,
125+ ]);
126+
127+ $ result = $ this ->validation ->run ($ data );
128+ $ this ->assertTrue ($ result );
129+ }
130+
89131 #[DataProvider('provideValidUrl ' )]
90132 public function testValidURL (?string $ url , bool $ isLoose , bool $ isStrict ): void
91133 {
0 commit comments