Skip to content

[Validator] Control traversal on class level #8617

Closed
@webmozart

Description

@webmozart

Currently, the validator will traverse objects that implement \Traversable if

  • the object was reached via a Valid constraint with traverse set to true
  • the parameter $traverse was set to true when calling Validator::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
{
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions