Skip to content

Commit

Permalink
fix: patch up closure error message issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mychidarko committed Nov 4, 2024
1 parent f02d7b2 commit c8d8090
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,17 @@ protected function test($rule, $valueToTest, $fieldName = 'item'): bool

if (is_callable($this->rules[$currentRule])) {
if (!call_user_func($this->rules[$currentRule], $valueToTest, $param, $fieldName)) {
if (empty($param)) {
$param = ['Item'];
}

$this->addError($fieldName, sprintf(
str_replace(
['{field}', '{Field}', '{value}'],
[$fieldName, ucfirst($fieldName), is_array($valueToTest) ? json_encode($valueToTest) : $valueToTest],
$this->messages[$currentRule] ?? '{Field} is invalid!'
),
...[$param],
...$param,
));
}

Expand Down

0 comments on commit c8d8090

Please sign in to comment.