UuidValidator
class UuidValidator extends ConstraintValidator
Validates whether the value is a valid UUID (also known as GUID).
Strict validation will allow a UUID as specified per RFC 4122. Loose validation will allow any type of UUID.
For better compatibility, both loose and strict, you should consider using a specialized UUID library like "ramsey/uuid" instead.
Constants
Properties
protected ExecutionContextInterface | $context | from ConstraintValidator |
Methods
Returns a string representation of the type of the value.
Returns a string representation of the value.
Returns a string representation of a list of values.
Details
protected string
formatTypeOf(mixed $value)
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.
protected string
formatValue(mixed $value, int $format = 0)
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.