Validator/UniqueEmailValidator.php
public function validate($value, Constraint $constraint): void
    {
        if (!$constraint instanceof UniqueEmail) {
            throw new UnexpectedTypeException($constraint, UniqueEmail::class);
        }

        if (null !== $value &&
            !is_scalar($value) &&
            !(\is_object($value) && method_exists($value, '__toString'))
        ) {
            throw new UnexpectedTypeException($value, 'string');
        }

        $value = (string) $value;

        if ('' === $value) {
            return;
        }

        if ($this->emailExists($constraint, $value)) {
            $this->context->buildViolation($constraint->message)
                ->setCode(UniqueEmail::NOT_UNIQUE_ERROR)
                ->setParameter('{{ value }}', $this->formatValue($value, self::OBJECT_TO_STRING | self::PRETTY_DATE))
                ->addViolation();
        }
    }
public function validate($value, Constraint $constraint): void
    {
        if (!$constraint instanceof UniqueEmail) {
            throw new UnexpectedTypeException($constraint, UniqueEmail::class);
        }

        if (null !== $value &&
            !is_scalar($value) &&
            !(\is_object($value) && method_exists($value, '__toString'))
        ) {
            throw new UnexpectedTypeException($value, 'string');
        }

        $value = (string) $value;

        if ('' === $value) {
            return;
        }

        if ($this->emailExists($constraint, $value)) {
            $this->context->buildViolation($constraint->message)
                ->setCode(UniqueEmail::NOT_UNIQUE_ERROR)
                ->setParameter('{{ value }}', $this->formatValue($value, self::OBJECT_TO_STRING | self::PRETTY_DATE))
                ->addViolation();
        }
    }
{@inheritdoc}