/** * @param Customer $object * @param Constraint $constraint */ public function validate($object, Constraint $constraint) { /** @var CustomerRepository $customerRepo */ $customerRepo = $this->entityManager->getRepository('SehBundle:Customer'); if ($customerRepo->emailExists($object->getEmail(), $object->getId())) { $this->context->addViolationAt('seh_bundle_sehbundle_account_customer_type.email', $constraint->message); } }