Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit ed70a3d

Browse files
committed
feat: added {{ element }} parameter to EachValue error message
1 parent fe76321 commit ed70a3d

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

docs/03x-rules-eachvalue.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ The following parameters are available:
4545
| `{{ value }}` | The current invalid value |
4646
| `{{ name }}` | Name of the invalid value |
4747
| `{{ key }}` | The key of the invalid iterable element |
48+
| `{{ element }}` | The value of the invalid iterable element |
4849
| `{{ message }}` | The rule message of the invalid iterable element |

src/Rule/EachValue.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ public function assert(mixed $value, string $name): void
2323
}
2424

2525
try {
26-
foreach ($value as $key => $input) {
27-
$this->validator->assert($input, $name);
26+
foreach ($value as $key => $element) {
27+
$this->validator->assert($element, $name);
2828
}
2929
}
3030
catch (ValidationException $exception) {
@@ -34,6 +34,7 @@ public function assert(mixed $value, string $name): void
3434
'value' => $value,
3535
'name' => $name,
3636
'key' => $key,
37+
'element' => $element,
3738
'message' => $exception->getMessage()
3839
]
3940
);

0 commit comments

Comments
 (0)