Skip to content

[Validator] Add @Validate constraint #17622

@backbone87

Description

@backbone87

To solve problems like #3622 I propose adding a new constraint named Validate. The parameters of this constraint are groups and foreignGroups.

The constraint validator of Validate starts a new subvalidation in the same context as the original validation, but uses foreignGroups:

public function validate($value, Constraint $constraint) {
  // ...
  $this->context->getValidator()
    ->inContext($this->context)
    ->validate($value, null, $constraint->foreignGroups);
}

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