public function validate($identity, Constraint $constraint)
    {
        if (null === $identity) {
            return;
        }

        if (!$identity instanceof Entity) {
            throw new UnexpectedTypeException($identity, Entity::class);
        }
        if (!$constraint instanceof SubjectIdentity) {
            throw new UnexpectedTypeException($constraint, SubjectIdentity::class);
        }

        $hasProvider = empty($identity->getProvider());
        $hasIdentifier = empty($identity->getIdentifier());

        if (($hasProvider || $hasIdentifier) && !($hasProvider && $hasIdentifier)) {
            $this->context
                ->buildViolation($constraint->identity_subject_must_be_selected)
                ->atPath('provider')
                ->addViolation();
        }
    }
public function validate($identity, Constraint $constraint)
    {
        if (null === $identity) {
            return;
        }

        if (!$identity instanceof Entity) {
            throw new UnexpectedTypeException($identity, Entity::class);
        }
        if (!$constraint instanceof SubjectIdentity) {
            throw new UnexpectedTypeException($constraint, SubjectIdentity::class);
        }

        $hasProvider = empty($identity->getProvider());
        $hasIdentifier = empty($identity->getIdentifier());

        if (($hasProvider || $hasIdentifier) && !($hasProvider && $hasIdentifier)) {
            $this->context
                ->buildViolation($constraint->identity_subject_must_be_selected)
                ->atPath('provider')
                ->addViolation();
        }
    }
{@inheritdoc}