diff --git a/src/EntityExistValidator.php b/src/EntityExistValidator.php index 2e60a23..27852ea 100644 --- a/src/EntityExistValidator.php +++ b/src/EntityExistValidator.php @@ -23,14 +23,14 @@ public function __construct(EntityManagerInterface $entityManager) public function validate($value, Constraint $constraint): void { - if (empty($value)) { - return; - } - if (!$constraint instanceof EntityExist) { throw new \LogicException(\sprintf('You can only pass %s constraint to this validator.', EntityExist::class)); } + if (null === $value || '' === $value) { + return; + } + if (empty($constraint->entity)) { throw new \LogicException(\sprintf('Must set "entity" on "%s" validator', EntityExist::class)); }