Closed
Description
Currently, the validator will traverse objects that implement \Traversable
if
- the object was reached via a
Valid
constraint withtraverse
set totrue
- the parameter
$traverse
was set totrue
when callingValidator::validate()
This has two negative consequences:
- it's impossible to specify only once that a specific class should never/always be traversed
- it's impossible to specify whether an object should be traversed when
Validator::validate()
is not called manually, but through another system (e.g. the Form component - see [Form][Bug] Embedded form validation bubbling #8557)
A solution would be to add configuration parameters for specifying the traversal policy on a class level, for example:
// not traversed by default
class Foo implements \IteratorAggregate
{
// ...
}
// traversed
/** @Assert\Traverse */
class Bar implements \IteratorAggregate
{
}
// traversed recursively
/** @Assert\Traverse(deep=true) */
class Baz implements \IteratorAggregate
{
}