-
Notifications
You must be signed in to change notification settings - Fork 770
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Each overwriting messages #1334
Comments
Unfortunatelly, this and other composite messages are completely broken in However, for Check out this test to see how the behavior changed. For |
Is this still an issue? I'm upgrading a site here, and I'm trying the following code: $v = new V();
$v->addRule(V::key('id', V::scalarVal()));
$v->addRule(V::key('fileReference', V::length(4, 35), false));
$v->addRule(V::key('scenario', V::length(3, 16), false));
$v->addRule(V::key('totalGrossMass', V::numericVal(), false));
$v->addRule(V::key('bolNumber', V::length(1, 35)->scalarVal(), false));
$v->addRule(V::key('arrivedDate', V::dateTime('Y-m-d H:i:s'), false));
$v->addRule(V::key('packages', V::intVal(), false));
$v->addRule(V::key('status', V::in(Status::toArray()), false));
try {
$v->assert($payload);
} catch (NestedValidationException $e) {
$messages = $e->getMessages();
} This gives me the following:
I would have expected the key to say |
In version 3.0, the array of messages will look somehow like this: [
'each' => [
'__root__' => 'Each item in `[["region": "Oregon", "country": "USA", "other": 123], ["street": "", "region": "Oregon", "country": "USA"], ["s ... ]` must be valid',
'allOf.1' => [
'__root__' => 'These rules must pass for `["region": "Oregon", "country": "USA", "other": 123]`',
'street' => 'street must be present',
'other' => 'other must be a string or must be null',
],
'allOf.2' => 'street must not be empty',
'allOf.3' => 'street must be a string',
],
] I'm pushing to get the new version released as soon as possible, but it might take some more time. Probably beginning of next year. |
When you validate the elements of an array (or iterable) using each, the messages get "overwritten" when you get the exception message.
The above var_dump results in
However, I would have expected
It is a little alarming that no exception is present for the first erroneous 'other' field.
Is there a different rule for this?
The text was updated successfully, but these errors were encountered: