ExecutionContextInterface

ExecutionContextInterface

interface ExecutionContextInterface

The context of a validation run.

The context collects all violations generated during the validation. By default, validators execute all validations in a new context:

$violations = $validator->validate($object);

When you make another call to the validator, while the validation is in progress, the violations will be isolated from each other:

public function validate($value, Constraint $constraint)
{
    $validator = $this->context->getValidator();

    // The violations are not added to $this->context
    $violations = $validator->validate($value);
}

However, if you want to add the violations to the current context, use the {@link ValidatorInterface::inContext()} method:

public function validate($value, Constraint $constraint)
{
    $validator = $