-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
@Assert\Valid() doesn't work with groups for more than one level of embeddance (Symfony 3.4) #24246
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
Having a small example project allowing to reproduce your issue would indeed be very helpful (I guess you won't need to set up any persistence layer as the issue should be reproducible using other constraints too, right?). |
Hello, I've created the project |
Status: Reviewed |
@kate-kate Thanks for the great reproducer. I was able to identify the issue. Can you confirm that #24983 does fix it for you? |
I think I have same problem as @kate-kate. I have constraint defined like
and then, I have group sequence validator
If I remove 'groups={"extendedPersonMailingAddressNotSame"}', everything works.
Unfortunatelly #24983 doesn't work for me. |
@KamilPesek I pushed another update to the PR. Can you check that too? |
This PR was merged into the 3.4 branch. Discussion ---------- [Validator] enter the context in which to validate | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #24246 | License | MIT | Doc PR | Commits ------- 7359cbe [Validator] enter the context in which to validate
Unfortunately no change for me. It still doesn't work in 3.4.3.
it works Any suggestions? |
@KamilPesek Please open a new issue and best also provide an example application that allows to reproduce your issue. |
Problem description
I've updated to 3.4 version to try using
@Assert\Valid()
with groups and found a bug.For example I have 3 entities: Contract, System, Part.
Contract has embedded Systems collection and "contract_valid" group. So it has systems field annotated like that:
System has embedded Parts collection and validation group "system_valid". And It has unique serialNumber
And Part itself has no embedded entities, but it also has unique field serialNumber, which is validated for "contract_valid", "system_valid" and its own "part_valid" validation groups
The problem is the following: when I try to save System with not unique Part serialNumber - validation error will be thrown successfully. But if I try to create Contract with not unique System serialNumber, I see PDO Exception instead of validation error:

Works the same way when I try to create (or update) Contract with valid System and not unique Part serialNumber:

Also, when I remove "contract_valid" group from Part annotations and from System parts
@Assert\Valid()
, it also works well for System (and obviously doesn't works for Part at all).I can create repository with represented bug, if helps.
The text was updated successfully, but these errors were encountered: