Skip to content

Commit 0318d87

Browse files
committed
fix: [BC] Validation::check() cannot specify non-default database group.
1 parent 0e73931 commit 0318d87

File tree

2 files changed

+6
-21
lines changed

2 files changed

+6
-21
lines changed

system/Validation/Validation.php

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -186,23 +186,6 @@ public function run(?array $data = null, ?string $group = null, ?string $dbGroup
186186
return $this->getErrors() === [];
187187
}
188188

189-
/**
190-
* Runs the validation process, returning true or false
191-
* determining whether validation was successful or not.
192-
*
193-
* @TODO the method signature is not good. Should make the checkValue()
194-
* method this method.
195-
*
196-
* @param array|bool|float|int|object|string|null $value
197-
* @param string[] $errors
198-
*/
199-
public function check($value, string $rule, array $errors = []): bool
200-
{
201-
$this->reset();
202-
203-
return $this->setRule('check', null, $rule, $errors)->run(['check' => $value]);
204-
}
205-
206189
/**
207190
* Runs the validation process, returning true or false determining whether
208191
* validation was successful or not.
@@ -212,7 +195,7 @@ public function check($value, string $rule, array $errors = []): bool
212195
* @param string[] $errors
213196
* @param string|null $dbGroup The database group to use.
214197
*/
215-
private function checkValue($value, $rules, array $errors = [], $dbGroup = null): bool
198+
public function check($value, $rules, array $errors = [], $dbGroup = null): bool
216199
{
217200
$this->reset();
218201

@@ -732,7 +715,7 @@ protected function fillPlaceholders(array $rules, array $data): array
732715

733716
// Validate the placeholder field
734717
$dbGroup = $data['DBGroup'] ?? null;
735-
if (! $validator->checkValue($data[$field], $placeholderRules, [], $dbGroup)) {
718+
if (! $validator->check($data[$field], $placeholderRules, [], $dbGroup)) {
736719
// if fails, do nothing
737720
continue;
738721
}

system/Validation/ValidationInterface.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ public function run(?array $data = null, ?string $group = null, ?string $dbGroup
3232
* Check; runs the validation process, returning true or false
3333
* determining whether or not validation was successful.
3434
*
35-
* @param array|bool|float|int|object|string|null $value Value to validate.
35+
* @param array|bool|float|int|object|string|null $value Value to validate.
36+
* @param array|string $rules
3637
* @param string[] $errors
38+
* @param string|null $dbGroup The database group to use.
3739
*
3840
* @return bool True if valid, else false.
3941
*/
40-
public function check($value, string $rule, array $errors = []): bool;
42+
public function check($value, $rules, array $errors = [], $dbGroup = null): bool;
4143

4244
/**
4345
* Takes a Request object and grabs the input data to use from its

0 commit comments

Comments
 (0)