-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Validator] All validation groups are not used on embedded constraints in a collection constraint #17675
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
Comments
I think the problem is the caching of already validated contraints. So the /**
* @Collection(
* fields={
* "foo" = {
* @NotBlank(groups={"foo"})
* }
* }
* )
* @Collection(
* fields={
* "foo" = {
* @Length(min="2", groups={"bar"})
* }
* }
* )
* @Collection(
* fields={
* "foo" = {
* @Length(min="4", groups={"baz"})
* }
* }
* )
*/ |
Thanks you @backbone87 it's work. 👍 I let this issue open because it seem to be a optimisation issue. What do you think @dunglas ? |
Thanks for reporting this issue! This looks like a bug to me. Status: reviewed |
I create a PR that fix the issue for collection constraint. It seem that the bug was introduce in Symfony 2.6 |
@webmozart I fix the issue in this PR #17696 Can you look at it ? Thank you. |
This PR was merged into the 3.4 branch. Discussion ---------- [Validator] Fixed grouped composite constraints | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #17675, #25888, #23480 | License | MIT | Doc PR | ~ From Lisbon :). Thanks @stof, @xabbuh for your help to finally fix this old issue. Commits ------- b53d911 [Validator] Fixed grouped composite constraints
Hi,
I don't know if it's a bug but it seem that all embedded constraints of a collection constraint are not applied when using validation groups.
I think that only the first validation group passed to the validator is used and the other are omitted.
With the following example if
$config
is equal to['foo' => 'a']
then with validation groups:['foo', 'bar', 'baz']
we have 0 violation (NotBlank
)['baz', 'bar', 'foo']
we have 1 violation (Lenght(min="4")
)['bar', 'baz', 'foo']
we have 1 violation (Lenght(min="2")
)Here the complete gist with the tests : https://gist.github.com/blazarecki/5dcb754be22dae4f0e53
Any idea ?
Thanks.
The text was updated successfully, but these errors were encountered: