PHP Class Symfony\Component\Validator\ConstraintValidator

Author: Bernhard Schussek ([email protected])
Inheritance: implements Symfony\Component\Validator\ConstraintValidatorInterface
Show file Open project: symfony/validator Class Usage Examples

Protected Properties

Property Type Description
$context ExecutionContextInterface2Dot5

Public Methods

Method Description
initialize ( Symfony\Component\Validator\Context\ExecutionContextInterface $context )

Protected Methods

Method Description
formatTypeOf ( mixed $value ) : string Returns a string representation of the type of the value.
formatValue ( mixed $value, integer $format ) : string Returns a string representation of the value.
formatValues ( array $values, integer $format ) : string Returns a string representation of a list of values.

Method Details

formatTypeOf() protected method

This method should be used if you pass the type of a value as message parameter to a constraint violation. Note that such parameters should usually not be included in messages aimed at non-technical people.
protected formatTypeOf ( mixed $value ) : string
$value mixed The value to return the type of
return string The type of the value

formatValue() protected method

This method returns the equivalent PHP tokens for most scalar types (i.e. "false" for false, "1" for 1 etc.). Strings are always wrapped in double quotes ("). Objects, arrays and resources are formatted as "object", "array" and "resource". If the $format bitmask contains the PRETTY_DATE bit, then {@link \DateTime} objects will be formatted as RFC-3339 dates ("Y-m-d H:i:s"). Be careful when passing message parameters to a constraint violation that (may) contain objects, arrays or resources. These parameters should only be displayed for technical users. Non-technical users won't know what an "object", "array" or "resource" is and will be confused by the violation message.
protected formatValue ( mixed $value, integer $format ) : string
$value mixed The value to format as string
$format integer A bitwise combination of the format constants in this class
return string The string representation of the passed value

formatValues() protected method

Each of the values is converted to a string using {@link formatValue()}. The values are then concatenated with commas.
See also: formatValue()
protected formatValues ( array $values, integer $format ) : string
$values array A list of values
$format integer A bitwise combination of the format constants in this class
return string The string representation of the value list

initialize() public method

public initialize ( Symfony\Component\Validator\Context\ExecutionContextInterface $context )
$context Symfony\Component\Validator\Context\ExecutionContextInterface

Property Details

$context protected property

protected ExecutionContextInterface2Dot5 $context
return ExecutionContextInterface2Dot5