diff --git a/src/Form.php b/src/Form.php index c78c025..68a7cb3 100644 --- a/src/Form.php +++ b/src/Form.php @@ -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, )); }