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

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

        if (!call_user_func($this->genderClass.'::isValid', $gender)) {
            $this->context
                ->buildViolation($constraint->invalid_gender)
                ->addViolation();
        }
    }
public function validate($gender, Constraint $constraint)
    {
        if (null === $gender) {
            return;
        }

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

        if (!call_user_func($this->genderClass.'::isValid', $gender)) {
            $this->context
                ->buildViolation($constraint->invalid_gender)
                ->addViolation();
        }
    }
{@inheritdoc}