Symfony\Component\Form\Extension\Validator\ValidatorTypeGuesser::guessRequiredForConstraint PHP Method

guessRequiredForConstraint() public method

Guesses whether a field is required based on the given constraint
public guessRequiredForConstraint ( Constraint $constraint ) : Symfony\Component\Form\Guess\Guess
$constraint Symfony\Component\Validator\Constraint The constraint to guess for
return Symfony\Component\Form\Guess\Guess The guess whether the field is required
    public function guessRequiredForConstraint(Constraint $constraint)
    {
        switch (get_class($constraint)) {
            case 'Symfony\Component\Validator\Constraints\NotNull':
                return new ValueGuess(
                    true,
                    Guess::HIGH_CONFIDENCE
                );
            case 'Symfony\Component\Validator\Constraints\NotBlank':
                return new ValueGuess(
                    true,
                    Guess::HIGH_CONFIDENCE
                );
            default:
                return new ValueGuess(
                    false,
                    Guess::LOW_CONFIDENCE
                );
        }
    }