[Form] Fixed the validation of form validation constraints #4625
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Validating the form constraints for each validation group results in
duplicated errors when several validation groups are used.
This is an attempt to fix #4427.
@bschussek can you look at it ? I'm not sure if it is the right way to fix it.
Looking at the code of the GraphWalker to debug this, I think we have an issue in the validator component itself (and the Form constraints being only the easiest way to trigger the issue): if a constraint is attached on an object in 2 validation groups and you use both groups when calling the validator, the ConstraintValidator is called twice. This is not something you will generally do in your constraint mapping, but the FormValidator was working in such a way: form constraints were validated for all validation groups of the form. However, I don't see how the GraphWalker could remember the constraint has already been validated for this instance as walkConstraint does not have access to the object.