diff --git a/system/Validation/Validation.php b/system/Validation/Validation.php index 853ba080402d..ec835c5212fd 100644 --- a/system/Validation/Validation.php +++ b/system/Validation/Validation.php @@ -300,7 +300,8 @@ protected function processRules( $arrayCallable = $isCallable && is_array($rule); $passed = false; - $param = false; + /** @var string|null $param */ + $param = null; if (! $isCallable && preg_match('/(.*?)\[(.*)\]/', $rule, $match)) { $rule = $match[1]; @@ -329,7 +330,7 @@ protected function processRules( if ($rule === 'field_exists') { $passed = $set->{$rule}($value, $param, $data, $error, $originalField); } else { - $passed = ($param === false) + $passed = ($param === null) ? $set->{$rule}($value, $error) : $set->{$rule}($value, $param, $data, $error, $field); } @@ -355,8 +356,6 @@ protected function processRules( $value = json_encode($value); } - $param = ($param === false) ? '' : $param; - $fieldForErrors = ($rule === 'field_exists') ? $originalField : $field; // @phpstan-ignore-next-line $error may be set by rule methods.