$data = [
'items' => [
['variantId' => 123, 'quantity' => 1],
]
];
$rules = [
'items' => [
new Each([
new Callback(callback: function(array $item) {
$result = new Result();
return $result;
}),
]),
new Each([
new Callback(callback: function(array $item) {
$result = new Result();
return $result;
}),
]),
]
];
$v = Container::get(ValidatorInterface::class);
$result = $v->validate($data, $rules);
What is the expected result?
$result has no error, no exceptions. Can use Each() many times.
What do you get instead?
TypeError
SomeClass::backend\controllers\{closure}(): Argument #1 ($item) must be of type array, int given, called in /var/www/project/vendor/yiisoft/validator/src/Rule/CallbackHandler.php on line 35
Thrown by second Callback().
$item was changes to int(123) - why?.
What steps will reproduce the problem?
Validate like this:
What is the expected result?
$result has no error, no exceptions. Can use Each() many times.
What do you get instead?
Thrown by second Callback().
$item
was changes toint(123)
- why?.Additional info