@@ -116,12 +116,15 @@ public function __construct($config, RendererInterface $view)
116116 * @param array|null $data The array of data to validate.
117117 * @param string|null $group The predefined group of rules to apply.
118118 * @param string|null $dbGroup The database group to use.
119+ *
120+ * @TODO Type ?string for $dbGroup should be removed.
121+ * See https://github.com/codeigniter4/CodeIgniter4/issues/6723
119122 */
120123 public function run (?array $ data = null , ?string $ group = null , ?string $ dbGroup = null ): bool
121124 {
122125 $ data ??= $ this ->data ;
123126
124- // i.e. is_unique
127+ // `DBGroup` is a reserved name. For is_unique and is_not_unique
125128 $ data ['DBGroup ' ] = $ dbGroup ;
126129
127130 $ this ->loadRuleSets ();
@@ -184,17 +187,28 @@ public function run(?array $data = null, ?string $group = null, ?string $dbGroup
184187 }
185188
186189 /**
187- * Runs the validation process, returning true or false
188- * determining whether validation was successful or not.
190+ * Runs the validation process, returning true or false determining whether
191+ * validation was successful or not.
189192 *
190193 * @param array|bool|float|int|object|string|null $value
194+ * @param array|string $rules
191195 * @param string[] $errors
196+ * @param string|null $dbGroup The database group to use.
192197 */
193- public function check ($ value , string $ rule , array $ errors = []): bool
198+ public function check ($ value , $ rules , array $ errors = [], $ dbGroup = null ): bool
194199 {
195200 $ this ->reset ();
196201
197- return $ this ->setRule ('check ' , null , $ rule , $ errors )->run (['check ' => $ value ]);
202+ return $ this ->setRule (
203+ 'check ' ,
204+ null ,
205+ $ rules ,
206+ $ errors
207+ )->run (
208+ ['check ' => $ value ],
209+ null ,
210+ $ dbGroup
211+ );
198212 }
199213
200214 /**
@@ -679,6 +693,7 @@ protected function fillPlaceholders(array $rules, array $data): array
679693
680694 foreach ($ placeholderFields as $ field ) {
681695 $ validator ??= Services::validation (null , false );
696+ assert ($ validator instanceof Validation);
682697
683698 $ placeholderRules = $ rules [$ field ]['rules ' ] ?? null ;
684699
@@ -699,7 +714,8 @@ protected function fillPlaceholders(array $rules, array $data): array
699714 }
700715
701716 // Validate the placeholder field
702- if (! $ validator ->check ($ data [$ field ], implode ('| ' , $ placeholderRules ))) {
717+ $ dbGroup = $ data ['DBGroup ' ] ?? null ;
718+ if (! $ validator ->check ($ data [$ field ], $ placeholderRules , [], $ dbGroup )) {
703719 // if fails, do nothing
704720 continue ;
705721 }
0 commit comments