From c8d80902e8430adad555d82eb08a698bc74e06b0 Mon Sep 17 00:00:00 2001 From: mychidarko Date: Mon, 4 Nov 2024 19:43:25 +0000 Subject: [PATCH] fix: patch up closure error message issue --- src/Form.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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, )); }