abstract class AbstractComparisonValidator extends ConstraintValidator
Provides a base class for the validation of property comparisons.
PRETTY_DATE | Whether to format {@link \DateTime} objects as RFC-3339 dates ("Y-m-d H:i:s"). |
OBJECT_TO_STRING | Whether to cast objects with a "__toString()" method to strings. |
protected ExecutionContextInterface | $context | from ConstraintValidator |
initialize(ExecutionContextInterface $context) Initializes the constraint validator. | from ConstraintValidator | |
string | formatTypeOf(mixed $value) Returns a string representation of the type of the value. | from ConstraintValidator |
string | formatValue(mixed $value, int $format = 0) Returns a string representation of the value. | from ConstraintValidator |
string | formatValues(array $values, int $format = 0) Returns a string representation of a list of values. | from ConstraintValidator |
__construct(PropertyAccessor $propertyAccessor = null) | ||
validate(mixed $value, Constraint $constraint) Checks if the passed value is valid. | ||
bool | compareValues(mixed $value1, mixed $value2) Compares the two given values to find if their relationship is valid. | |
string|null | getErrorCode() Returns the error code used if the comparison fails. |
Initializes the constraint validator.
ExecutionContextInterface | $context | The current validation context |
Returns a string representation of the type of the value.
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.
mixed | $value | The value to return the type of |
string | The type of the value |
Returns a string representation of the value.
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.
mixed | $value | The value to format as string |
int | $format | A bitwise combination of the format constants in this class |
string | The string representation of the passed value |
Returns a string representation of a list of values.
Each of the values is converted to a string using {@link formatValue()}. The values are then concatenated with commas.
array | $values | A list of values |
int | $format | A bitwise combination of the format constants in this class |
string | The string representation of the value list |
formatValue() |
PropertyAccessor | $propertyAccessor |
Checks if the passed value is valid.
mixed | $value | The value that should be validated |
Constraint | $constraint | The constraint for the validation |
Compares the two given values to find if their relationship is valid.
mixed | $value1 | The first value to compare |
mixed | $value2 | The second value to compare |
bool | true if the relationship is valid, false otherwise |
Returns the error code used if the comparison fails.
string|null | The error code or null if no code should be set |
© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.html