/**
  * {@inheritDoc}
  */
 public function validate($id, Constraint $constraint)
 {
     $mainEntity = $constraint->getEntity();
     // Invalid if no main entity is set
     if (!$mainEntity) {
         return $this->addViolation($id, $constraint);
     }
     $relatedEntity = $constraint->getMapper()->findBy(['id' => $id, $constraint->getIdField() => $mainEntity->getId()]);
     // Invalid if related entity not found
     if (!$relatedEntity instanceof AbstractEntity) {
         return $this->addViolation($id, $constraint);
     }
     // Otherwise valid
     return;
 }