Symfony2 API
Class

Symfony\Component\Form\Extension\Validator\ValidatorTypeGuesser

class ValidatorTypeGuesser implements FormTypeGuesserInterface

Methods

__construct(MetadataFactoryInterface $metadataFactory)

TypeGuess guessType(string $class, string $property)

Returns a field guess for a property name of a class

Guess guessRequired(string $class, string $property)

Returns a guess whether a property of a class is required

Guess guessMaxLength(string $class, string $property)

Returns a guess about the field's maximum length

Guess guessPattern(string $class, string $property)

Returns a guess about the field's pattern

TypeGuess guessTypeForConstraint(Constraint $constraint)

Guesses a field class name for a given constraint

Guess guessRequiredForConstraint(Constraint $constraint)

Guesses whether a field is required based on the given constraint

Guess guessMaxLengthForConstraint(Constraint $constraint)

Guesses a field's maximum length based on the given constraint

Guess guessPatternForConstraint(Constraint $constraint)

Guesses a field's pattern based on the given constraint

Details

at line 25
public __construct(MetadataFactoryInterface $metadataFactory)

Parameters

MetadataFactoryInterface $metadataFactory

at line 33
public TypeGuess guessType(string $class, string $property)

Returns a field guess for a property name of a class

Parameters

string $class The fully qualified class name
string $property The name of the property to guess for

Return Value

TypeGuess A guess for the field's type and options

at line 45
public Guess guessRequired(string $class, string $property)

Returns a guess whether a property of a class is required

Parameters

string $class The fully qualified class name
string $property The name of the property to guess for

Return Value

Guess A guess for the field's required setting

at line 59
public Guess guessMaxLength(string $class, string $property)

Returns a guess about the field's maximum length

Parameters

string $class The fully qualified class name
string $property The name of the property to guess for

Return Value

Guess A guess for the field's maximum length

at line 71
public Guess guessPattern(string $class, string $property)

Returns a guess about the field's pattern

- When you have a min value, you guess a min length of this min (LOW_CONFIDENCE) , lines below
- If this value is a float type, this is wrong so you guess null with MEDIUM_CONFIDENCE to override the previous guess.
Example:
You want a float greater than 5, 4.512313 is not valid but length(4.512314) > length(5)

Parameters

string $class The fully qualified class name
string $property The name of the property to guess for

Return Value

Guess A guess for the field's required pattern

at line 87
public TypeGuess guessTypeForConstraint(Constraint $constraint)

Guesses a field class name for a given constraint

Parameters

Constraint $constraint The constraint to guess for

Return Value

TypeGuess The guessed field class and options

at line 176
public Guess guessRequiredForConstraint(Constraint $constraint)

Guesses whether a field is required based on the given constraint

Parameters

Constraint $constraint The constraint to guess for

Return Value

Guess The guess whether the field is required

at line 195
public Guess guessMaxLengthForConstraint(Constraint $constraint)

Guesses a field's maximum length based on the given constraint

Parameters

Constraint $constraint The constraint to guess for

Return Value

Guess The guess for the maximum length

at line 221
public Guess guessPatternForConstraint(Constraint $constraint)

Guesses a field's pattern based on the given constraint

Parameters

Constraint $constraint The constraint to guess for

Return Value

Guess The guess for the pattern