Skip to content

[Validator][GroupSequence] GroupSequence validation ignores PropertyMetadata of parent classes #19387

@senaria

Description

@senaria

GroupSequences do not seem to run property validations of parent classes. Class constraints are recognized correctly and run without problem but not those on the Parent::$property's.

For example:

/**
 * @Assert\ParentClassConstraint()
 */
class Parent
{
    /**
    * @Assert\NotNull()
    */
    protected $property;
}

/**
 * @Assert\ChildClassConstraint()
 * @Assert\GroupSequence({"Child", "Extra"})
 */
class Child extends Parent
{
   /**
    * @Assert\NotNull(groups={"Extra"})
    */
    private $anotherProperty;
}

When I run the validation on Child the group sequence will run @Assert\ParentClassConstraint() of Parent, @Assert\ChildClassConstraint() of Child and @Assert\NotNull(groups={"Extra"}) of Child. However, it will not run @Assert\NotNull() of Parent

I think I found the cause of the problem: \Symfony\Component\Validator\Mapping\ClassMetadata::mergeConstraints Does not seem to add them to the PropertyMetadata::$constraintsByGroup.

I will create a patch with tests to see if i can suggest a fix.

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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy