-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
[Validator] Breaking changes in Collection #53455
Comments
I tested your solution. I have this code: $constraints['packAccessory'] = [new Assert\NotNull()];
$violations = $this->validator->validate(
$inputValues,
new Assert\Collection($constraints),
// new Assert\Collection([
// 'fields' => $constraints,
// ]),
); I run the tests and get an error 500:
I tested second version: $violations = $this->validator->validate(
$inputValues,
// new Assert\Collection($constraints),
new Assert\Collection([
'fields' => $constraints,
]),
); I run the tests and get an error 422:
|
@axzx I'm having trouble reproducing your problem. What is the value of |
$inputValues = ['packAccessory' => null];
$constraints = ['packAccessory' => [new Assert\NotNull()]];
$violations = $this->validator->validate(
$inputValues,
new Assert\Collection($constraints),
); |
@axzx I've tried your example and didn't get the error. Are you sure you're using the fix? |
OK, your solution actually worked, but it stopped working in a certain case. what about this: $inputValues = [];
$constraints = [];
$violations = $this->validator->validate(
$inputValues,
new Assert\Collection(['fields' => $constraints]),
); ? I get an error response: Applications will again stop working after this change. |
@axzx Yes, unfortunately, this all comes down to the fact that there's no way of knowing whether |
@HypeMC Could the |
@axzx Reserving |
… (xabbuh, HypeMC) This PR was merged into the 5.4 branch. Discussion ---------- [Validator] Fix fields without constraints in `Collection` | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #53133 (comment), Fix #53455 | License | MIT Continuation of #53443. Commits ------- f6217d8 [Validator] Fix fields without constraints in `Collection` b341535 deal with fields for which no constraints have been configured
Symfony version(s) affected
5.4
Description
Before this symfony/validator@b125357
After this symfony/validator@b125357
@nicolas-grekas My application stopped working as before after this commit.
How to reproduce
Possible Solution
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: