Skip to content

GroupSequences execute next group if first fail #25717

Closed
@sobhan93

Description

@sobhan93
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 4.0.3

When form is submitted, both groups "Users' and 'Strict' are validated even if there are violations in 'Users'.

When put something like "123" on username and password,expected "This value is too short. It should have 6 characters or more." but "I am passwordLegal" message appears.

class Users
{
    public static function loadValidatorMetadata(ClassMetadata $metadata)
    {
        $metadata->addPropertyConstraint('username', new Assert\NotBlank());
        $metadata->addPropertyConstraint('password', new Assert\NotBlank());
        $metadata->addPropertyConstraint('username', new Assert\Length(array(
            'min' => 6,
            'max' => 12
        )));
        
        $metadata->addPropertyConstraint('password', new Assert\Length(array(
            'min' => 6
        )));
        
        $metadata->addGetterMethodConstraint('password', 'passwordLegal', new Assert\IsTrue(array(
            'message' => 'The password cannot match your username',
            'groups' => array(
                'Strict'
            )
        )));
        $metadata->setGroupSequence(array(
            'Users',
            'Strict'
        ));
    }

    public function passwordLegal()
    {
        die("I am passwordLegal");
        return $this->password !== $this->username;
    }
}

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