You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
throws a \Symfony\Component\Validator\Exception\ConstraintDefinitionException with message Traversal was enabled for "App\Entity\Book", but this class does not implement "\Traversable". (from vendor/symfony/validator/Validator/RecursiveContextualValidator.php).
Currently, it is possible whether to traverse a Traversable object or not in the Valid constraint:
/**
* @Assert\Valid(traverse=true)
*/
private $tags = new TagList();
(actually, true is the default)
In this way, the validator will iterate the TagList instance and validate each of the contained objects. You can also set "traverse" to false to disable iteration.
What if you want to specify, that TagList instances should always (or never) be traversed? That's currently not possible.
I understand that the Traverse constraint is not at all a "shorthand" for Valid constraints on all nested objects, but rather a means to always disable validator traversal on a custom \Traversable class. (But I may be wrong)
The text was updated successfully, but these errors were encountered:
This PR was merged into the 3.4 branch.
Discussion
----------
[Validator] Fixed `Traverse` constraint reference
I'm sorry I've messed up things in #11310. Now I see that I missed #12967, this fixes it.
Commits
-------
ef5c989 [Validator] Fixed `Traverse` constraint reference
Uh oh!
There was an error while loading. Please reload this page.
#11310 (comment)
The current code from https://symfony.com/doc/4.4/reference/constraints/Traverse.html:
throws a
\Symfony\Component\Validator\Exception\ConstraintDefinitionException
with messageTraversal was enabled for "App\Entity\Book", but this class does not implement "\Traversable".
(fromvendor/symfony/validator/Validator/RecursiveContextualValidator.php
).From symfony/symfony#10287:
I understand that the
Traverse
constraint is not at all a "shorthand" forValid
constraints on all nested objects, but rather a means to always disable validator traversal on a custom\Traversable
class. (But I may be wrong)The text was updated successfully, but these errors were encountered: