function it_validates_deprecated_context($constraint, DeprecatedContext $context) { $context->getGroup()->shouldBeCalled(); $context->getRoot()->shouldBeCalled(); $context->validateValue('some value', $constraint->constraints, Argument::any(), Argument::any())->shouldBeCalled(); $this->initialize($context); $this->validate('some value', $constraint); }
/** * @param \Symfony\Component\Validator\Constraint $constraint */ protected function validate(Constraint $constraint) { $subPath = (string) $this->getCurrentPropertyPath(); if ($this->context instanceof LegacyExecutionContextInterface) { $this->context->validateValue($this->getValue(), $constraint, $subPath, $this->group); } else { $this->context->getValidator()->inContext($this->context)->atPath($subPath)->validate($this->getValue(), $constraint, array($this->group)); } }
public function checkEmailList($value, ExecutionContextInterface $context) { $list = preg_split('/[,;]/', $value); $emailValidator = new Constraints\Email(); foreach ($list as $email) { $email = trim($email); $context->validateValue($email, $emailValidator); } }
/** * @param \Symfony\Component\Validator\Constraint $constraint */ protected function validate(Constraint $constraint) { $subPath = (string) $this->getCurrentPropertyPath(); $this->context->validateValue($this->getValue(), $constraint, $subPath, $this->group); }