-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
AbstractComparisonValidator does not look at root if object is null when using propertyPath #29719
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
possible duplicate of #28987 ?? |
@gmponos I don't think so. I looked at that Issue before submitting mine, that one explicitly talks about using the form component. It's related to the same code, but I think it's a different issue. |
I think the proposed solution will not work correctly as the property path would have to be adapted as soon as the array is nested in another data structure (as that makes the root of the context vary). Thus, I don't see that the current behaviour can be changed and the we best we can do is add a hint to the docs which explains that the |
@xabbuh Hmm, yeah, that might definitely be an issue then... |
Similar issue: |
Hey, thanks for your report! |
Friendly reminder that this issue exists. If I don't hear anything I'll close this. |
closing for the reasons explained in #29719 (comment) |
Symfony version(s) affected: 4.2.x
Description
When using the Validator component with a Comparison constraint, the AbstractComparisonValidator only looks at the ExecutionContext object to compare values, not the root, see these lines: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php#L51-L53
How to reproduce
Validate an array of data with a comparison constraint:
Possible Solution
If the ExecutionContext object is null, use the root of the ExecutionContext to get the compared value.
The text was updated successfully, but these errors were encountered: