@@ -190,6 +190,9 @@ public function run(?array $data = null, ?string $group = null, ?string $dbGroup
190
190
* Runs the validation process, returning true or false
191
191
* determining whether validation was successful or not.
192
192
*
193
+ * @TODO the method signature is not good. Should make the checkValue()
194
+ * method this method.
195
+ *
193
196
* @param array|bool|float|int|object|string|null $value
194
197
* @param string[] $errors
195
198
*/
@@ -200,6 +203,31 @@ public function check($value, string $rule, array $errors = []): bool
200
203
return $ this ->setRule ('check ' , null , $ rule , $ errors )->run (['check ' => $ value ]);
201
204
}
202
205
206
+ /**
207
+ * Runs the validation process, returning true or false determining whether
208
+ * validation was successful or not.
209
+ *
210
+ * @param array|bool|float|int|object|string|null $value
211
+ * @param array|string $rules
212
+ * @param string[] $errors
213
+ * @param string|null $dbGroup The database group to use.
214
+ */
215
+ private function checkValue ($ value , $ rules , array $ errors = [], $ dbGroup = null ): bool
216
+ {
217
+ $ this ->reset ();
218
+
219
+ return $ this ->setRule (
220
+ 'check ' ,
221
+ null ,
222
+ $ rules ,
223
+ $ errors
224
+ )->run (
225
+ ['check ' => $ value ],
226
+ null ,
227
+ $ dbGroup
228
+ );
229
+ }
230
+
203
231
/**
204
232
* Runs all of $rules against $field, until one fails, or
205
233
* all of them have been processed. If one fails, it adds
@@ -682,6 +710,7 @@ protected function fillPlaceholders(array $rules, array $data): array
682
710
683
711
foreach ($ placeholderFields as $ field ) {
684
712
$ validator ??= Services::validation (null , false );
713
+ assert ($ validator instanceof Validation);
685
714
686
715
$ placeholderRules = $ rules [$ field ]['rules ' ] ?? null ;
687
716
@@ -702,7 +731,8 @@ protected function fillPlaceholders(array $rules, array $data): array
702
731
}
703
732
704
733
// Validate the placeholder field
705
- if (! $ validator ->check ($ data [$ field ], implode ('| ' , $ placeholderRules ))) {
734
+ $ dbGroup = $ data ['DBGroup ' ] ?? null ;
735
+ if (! $ validator ->checkValue ($ data [$ field ], $ placeholderRules , [], $ dbGroup )) {
706
736
// if fails, do nothing
707
737
continue ;
708
738
}
0 commit comments