Skip to content

Commit 61e476a

Browse files
committed
refactor: pass valid type value to method/function
1 parent 92820fa commit 61e476a

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

system/Validation/Validation.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,8 @@ protected function processRules(string $field, ?string $label, $value, $rules =
295295
$value = json_encode($value);
296296
}
297297

298-
$this->errors[$field] = $error ?? $this->getErrorMessage($rule, $field, $label, $param, $value);
298+
$param = ($param === false) ? '' : $param;
299+
$this->errors[$field] = $error ?? $this->getErrorMessage($rule, $field, $label, $param, (string) $value);
299300

300301
return false;
301302
}
@@ -646,6 +647,9 @@ public function setError(string $field, string $error): ValidationInterface
646647
*/
647648
protected function getErrorMessage(string $rule, string $field, ?string $label = null, ?string $param = null, ?string $value = null): string
648649
{
650+
$param = $param ?? '';
651+
652+
// Check if custom message has been defined by user
649653
if (isset($this->customErrors[$field][$rule])) {
650654
$message = lang($this->customErrors[$field][$rule]);
651655
} else {

0 commit comments

Comments
 (0)