Documentation

UrlValidator extends ConstraintValidator
in package

Base class for constraint validators.

Tags
author

Bernhard Schussek bschussek@gmail.com

Table of Contents

Constants

OBJECT_TO_STRING  = 2
Whether to cast objects with a "__toString()" method to strings.
PATTERN  = '~^ (%s):// # protocol (((?:[\\_\\.\\pL\\pN-]|%%[0-9A-Fa-f]{2})+:)?((?:[\\_\\.\\pL\\pN-]|%%[0-9A-Fa-f]{2})+)@)? # basic auth ( (?: (?:xn--[a-z0-9-]++\\.)*+xn--[a-z0-9-]++ # a domain name using punycode | (?:[\\pL\\pN\\pS\\pM\\-\\_]++\\.)+[\\pL\\pN\\pM]++ # a multi-level domain name | [a-z0-9\\-\\_]++ # a single-level domain name )\\.? | # or \\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3} # an IP address | # or \\[ (?:(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){6})(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:::(?:(?:(?:[0-9a-f]{1,4})):){5})(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:[0-9a-f]{1,4})))?::(?:(?:(?:[0-9a-f]{1,4})):){4})(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9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a-f]{1,4})))?::)))) \\] # an IPv6 address ) (:[0-9]+)? # a port (optional) (?:/ (?:[\\pL\\pN\\-._\\~!$&\'()*+,;=:@]|%%[0-9A-Fa-f]{2})* )* # a path (?:\\? (?:[\\pL\\pN\\-._\\~!$&\'\\[\\]()*+,;=:@/?]|%%[0-9A-Fa-f]{2})* )? # a query (optional) (?:\\# (?:[\\pL\\pN\\-._\\~!$&\'()*+,;=:@/?]|%%[0-9A-Fa-f]{2})* )? # a fragment (optional) $~ixu'
PRETTY_DATE  = 1
Whether to format {@link \DateTime} objects, either with the {@link \IntlDateFormatter} (if it is available) or as RFC-3339 dates ("Y-m-d H:i:s").

Properties

$context  : ExecutionContextInterface

Methods

initialize()  : mixed
Initializes the constraint validator.
validate()  : mixed
{@inheritdoc}
formatTypeOf()  : string
Returns a string representation of the type of the value.
formatValue()  : string
Returns a string representation of the value.
formatValues()  : string
Returns a string representation of a list of values.

Constants

OBJECT_TO_STRING

Whether to cast objects with a "__toString()" method to strings.

public mixed OBJECT_TO_STRING = 2

PATTERN

public mixed PATTERN = '~^ (%s):// # protocol (((?:[\\_\\.\\pL\\pN-]|%%[0-9A-Fa-f]{2})+:)?((?:[\\_\\.\\pL\\pN-]|%%[0-9A-Fa-f]{2})+)@)? # basic auth ( (?: (?:xn--[a-z0-9-]++\\.)*+xn--[a-z0-9-]++ # a domain name using punycode | (?:[\\pL\\pN\\pS\\pM\\-\\_]++\\.)+[\\pL\\pN\\pM]++ # a multi-level domain name | [a-z0-9\\-\\_]++ # a single-level domain name )\\.? | # or \\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3} # an IP address | # or \\[ (?:(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){6})(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:::(?:(?:(?:[0-9a-f]{1,4})):){5})(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:[0-9a-f]{1,4})))?::(?:(?:(?:[0-9a-f]{1,4})):){4})(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){0,1}(?:(?:[0-9a-f]{1,4})))?::(?:(?:(?:[0-9a-f]{1,4})):){3})(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){0,2}(?:(?:[0-9a-f]{1,4})))?::(?:(?:(?:[0-9a-f]{1,4})):){2})(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){0,3}(?:(?:[0-9a-f]{1,4})))?::(?:(?:[0-9a-f]{1,4})):)(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){0,4}(?:(?:[0-9a-f]{1,4})))?::)(?:(?:(?:(?:(?:[0-9a-f]{1,4})):(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){0,5}(?:(?:[0-9a-f]{1,4})))?::)(?:(?:[0-9a-f]{1,4})))|(?:(?:(?:(?:(?:(?:[0-9a-f]{1,4})):){0,6}(?:(?:[0-9a-f]{1,4})))?::)))) \\] # an IPv6 address ) (:[0-9]+)? # a port (optional) (?:/ (?:[\\pL\\pN\\-._\\~!$&\'()*+,;=:@]|%%[0-9A-Fa-f]{2})* )* # a path (?:\\? (?:[\\pL\\pN\\-._\\~!$&\'\\[\\]()*+,;=:@/?]|%%[0-9A-Fa-f]{2})* )? # a query (optional) (?:\\# (?:[\\pL\\pN\\-._\\~!$&\'()*+,;=:@/?]|%%[0-9A-Fa-f]{2})* )? # a fragment (optional) $~ixu'

PRETTY_DATE

Whether to format {@link \DateTime} objects, either with the {@link \IntlDateFormatter} (if it is available) or as RFC-3339 dates ("Y-m-d H:i:s").

public mixed PRETTY_DATE = 1

Properties

Methods

formatTypeOf()

Returns a string representation of the type of the value.

protected formatTypeOf(mixed $value) : string

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.

Parameters
$value : mixed
Return values
string

formatValue()

Returns a string representation of the value.

protected formatValue(mixed $value[, int $format = 0 ]) : string

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 objects will be formatted with the . If it is not available, they 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.

Parameters
$value : mixed
$format : int = 0

A bitwise combination of the format constants in this class

Return values
string

formatValues()

Returns a string representation of a list of values.

protected formatValues(array<string|int, mixed> $values[, int $format = 0 ]) : string

Each of the values is converted to a string using . The values are then concatenated with commas.

Parameters
$values : array<string|int, mixed>

A list of values

$format : int = 0

A bitwise combination of the format constants in this class

Tags
see
formatValue()
Return values
string

        
On this page

Search results