Hostname
extends AbstractValidator
in package
Please note there are two standalone test scripts for testing IDN characters due to problems with file encoding.
The first is tests/Laminas/Validator/HostnameTestStandalone.php which is designed to be run on the command line.
The second is tests/Laminas/Validator/HostnameTestForm.php which is designed to be run via HTML to allow users to test entering UTF-8 characters in a form.
Table of Contents
Constants
- ALLOW_ALL = 15
- ALLOW_DNS = 1
- ALLOW_IP = 2
- ALLOW_LOCAL = 4
- ALLOW_URI = 8
- CANNOT_DECODE_PUNYCODE = 'hostnameCannotDecodePunycode'
- INVALID = 'hostnameInvalid'
- INVALID_DASH = 'hostnameDashCharacter'
- INVALID_HOSTNAME = 'hostnameInvalidHostname'
- INVALID_HOSTNAME_SCHEMA = 'hostnameInvalidHostnameSchema'
- INVALID_LOCAL_NAME = 'hostnameInvalidLocalName'
- INVALID_URI = 'hostnameInvalidUri'
- IP_ADDRESS_NOT_ALLOWED = 'hostnameIpAddressNotAllowed'
- LOCAL_NAME_NOT_ALLOWED = 'hostnameLocalNameNotAllowed'
- UNDECIPHERABLE_TLD = 'hostnameUndecipherableTld'
- UNKNOWN_TLD = 'hostnameUnknownTld'
Properties
- $messageTemplates : array<string, string>
- $messageVariables : array<string, mixed>
- $options : array<string, mixed>
- $abstractOptions : AbstractOptions|array<string, mixed>
- $defaultTranslator : TranslatorInterface
- Default translation object for all validate objects
- $defaultTranslatorTextDomain : string
- Default text domain to be used with translator
- $idnLength : array<string, array<int, int>>
- $messageLength : int
- Limits the maximum returned length of an error message
- $messageTemplates : array<string|int, mixed>
- $messageVariables : array<string|int, mixed>
- $options : array<string|int, mixed>
- Options for the hostname validator
- $tld : null|false|string
- $validIdns : array<string, string|array<int, string>>
- Array for valid Idns
- $validTlds : array<string|int, string>
- Array of valid top-level-domains IanaVersion 2022072400
- $value : mixed
- The value to be validated
Methods
- __construct() : mixed
- Sets validator options.
- __get() : mixed
- Magic function returns the value of the requested property, if and only if it is the value or a message variable.
- __invoke() : bool
- Invoke as command
- getAllow() : int
- Returns the allow option
- getDefaultTranslator() : TranslatorInterface|null
- Get default translation object for all validate objects
- getDefaultTranslatorTextDomain() : string
- Get default translation text domain for all validate objects
- getIdnCheck() : bool
- Returns the set idn option
- getIpValidator() : Ip
- Returns the set ip validator
- getMessageLength() : int
- Returns the maximum allowed message length
- getMessages() : array<string, string>
- Returns array of validation failure messages
- getMessageTemplates() : array<string, string>
- Returns the message templates from the validator
- getMessageVariables() : array<int, string>
- Returns an array of the names of variables that are used in constructing validation failure messages
- getOption() : mixed
- Returns an option
- getOptions() : array<string, mixed>
- Returns all available options
- getTldCheck() : bool
- Returns the set tld option
- getTranslator() : TranslatorInterface|null
- Return translation object
- getTranslatorTextDomain() : string
- Return the translation text domain
- hasDefaultTranslator() : bool
- Is there a default translation object set?
- hasTranslator() : bool
- Does this validator have its own specific translator?
- isTranslatorEnabled() : bool
- Is translation enabled?
- isValid() : bool
- Defined by Interface
- isValueObscured() : bool
- Retrieve flag indicating whether or not value should be obfuscated in messages
- setAllow() : $this
- Sets the allow option
- setDefaultTranslator() : void
- Set default translation object for all validate objects
- setDefaultTranslatorTextDomain() : void
- Set default translation text domain for all validate objects
- setIpValidator() : self
- setMessage() : $this
- Sets the validation failure message template for a particular key
- setMessageLength() : void
- Sets the maximum allowed message length
- setMessages() : $this
- Sets validation failure message templates given as an array, where the array keys are the message keys, and the array values are the message template strings.
- setOptions() : $this
- Sets one or multiple options
- setTranslator() : $this
- Set translation object
- setTranslatorEnabled() : $this
- Indicate whether or not translation should be enabled
- setTranslatorTextDomain() : $this
- Set translation text domain
- setValueObscured() : $this
- Set flag indicating whether or not value should be obfuscated in messages
- useIdnCheck() : $this
- Set whether IDN domains are validated
- useTldCheck() : $this
- Set whether the TLD element of a hostname is validated
- createMessage() : null|string
- Constructs and returns a validation failure message with the given message key and value.
- decodePunycode() : string|false
- Decodes a punycode encoded string to it's original utf8 string Returns false in case of a decoding failure.
- error() : void
- getValue() : mixed
- Returns the validation value
- setValue() : void
- Sets the value to be validated and clears the messages and errors arrays
- translateMessage() : string
- Translate a validation message
Constants
ALLOW_ALL
public
mixed
ALLOW_ALL
= 15
ALLOW_DNS
public
mixed
ALLOW_DNS
= 1
ALLOW_IP
public
mixed
ALLOW_IP
= 2
ALLOW_LOCAL
public
mixed
ALLOW_LOCAL
= 4
ALLOW_URI
public
mixed
ALLOW_URI
= 8
CANNOT_DECODE_PUNYCODE
public
mixed
CANNOT_DECODE_PUNYCODE
= 'hostnameCannotDecodePunycode'
INVALID
public
mixed
INVALID
= 'hostnameInvalid'
INVALID_DASH
public
mixed
INVALID_DASH
= 'hostnameDashCharacter'
INVALID_HOSTNAME
public
mixed
INVALID_HOSTNAME
= 'hostnameInvalidHostname'
INVALID_HOSTNAME_SCHEMA
public
mixed
INVALID_HOSTNAME_SCHEMA
= 'hostnameInvalidHostnameSchema'
INVALID_LOCAL_NAME
public
mixed
INVALID_LOCAL_NAME
= 'hostnameInvalidLocalName'
INVALID_URI
public
mixed
INVALID_URI
= 'hostnameInvalidUri'
IP_ADDRESS_NOT_ALLOWED
public
mixed
IP_ADDRESS_NOT_ALLOWED
= 'hostnameIpAddressNotAllowed'
LOCAL_NAME_NOT_ALLOWED
public
mixed
LOCAL_NAME_NOT_ALLOWED
= 'hostnameLocalNameNotAllowed'
UNDECIPHERABLE_TLD
public
mixed
UNDECIPHERABLE_TLD
= 'hostnameUndecipherableTld'
UNKNOWN_TLD
public
mixed
UNKNOWN_TLD
= 'hostnameUnknownTld'
Properties
$messageTemplates
public
array<string, string>
$messageTemplates
$messageVariables
public
array<string, mixed>
$messageVariables
$options
public
array<string, mixed>
$options
$abstractOptions
protected
AbstractOptions|array<string, mixed>
$abstractOptions
= [
'messages' => [],
// Array of validation failure messages
'messageTemplates' => [],
// Array of validation failure message templates
'messageVariables' => [],
// Array of additional variables available for validation failure messages
'translator' => null,
// Translation object to used -> Translator\TranslatorInterface
'translatorTextDomain' => null,
// Translation text domain
'translatorEnabled' => true,
// Is translation enabled?
'valueObscured' => false,
]
$defaultTranslator
Default translation object for all validate objects
protected
static TranslatorInterface
$defaultTranslator
$defaultTranslatorTextDomain
Default text domain to be used with translator
protected
static string
$defaultTranslatorTextDomain
= 'default'
$idnLength
protected
array<string, array<int, int>>
$idnLength
= ['BIZ' => [5 => 17, 11 => 15, 12 => 20], 'CN' => [1 => 20], 'COM' => [3 => 17, 5 => 20], 'HK' => [1 => 15], 'INFO' => [4 => 17], 'KR' => [1 => 17], 'NET' => [3 => 17, 5 => 20], 'ORG' => [6 => 17], 'TW' => [1 => 20], 'امارات' => [1 => 30], 'الاردن' => [1 => 30], 'السعودية' => [1 => 30], 'تونس' => [1 => 30], 'مصر' => [1 => 30], 'فلسطين' => [1 => 30], 'شبكة' => [1 => 30], '中国' => [1 => 20], '中國' => [1 => 20], '香港' => [1 => 20], '台湾' => [1 => 20], '台灣' => [1 => 20]]
$messageLength
Limits the maximum returned length of an error message
protected
static int
$messageLength
= -1
$messageTemplates
protected
array<string|int, mixed>
$messageTemplates
= [self::CANNOT_DECODE_PUNYCODE => "The input appears to be a DNS hostname but the given punycode notation cannot be decoded", self::INVALID => "Invalid type given. String expected", self::INVALID_DASH => "The input appears to be a DNS hostname but contains a dash in an invalid position", self::INVALID_HOSTNAME => "The input does not match the expected structure for a DNS hostname", self::INVALID_HOSTNAME_SCHEMA => "The input appears to be a DNS hostname but cannot match against hostname schema for TLD '%tld%'", self::INVALID_LOCAL_NAME => "The input does not appear to be a valid local network name", self::INVALID_URI => "The input does not appear to be a valid URI hostname", self::IP_ADDRESS_NOT_ALLOWED => "The input appears to be an IP address, but IP addresses are not allowed", self::LOCAL_NAME_NOT_ALLOWED => "The input appears to be a local network name but local network names are not allowed", self::UNDECIPHERABLE_TLD => "The input appears to be a DNS hostname but cannot extract TLD part", self::UNKNOWN_TLD => "The input appears to be a DNS hostname but cannot match TLD against known list"]
$messageVariables
protected
array<string|int, mixed>
$messageVariables
= ['tld' => 'tld']
$options
Options for the hostname validator
protected
array<string|int, mixed>
$options
= [
'allow' => self::ALLOW_DNS,
// Allow these hostnames
'useIdnCheck' => true,
// Check IDN domains
'useTldCheck' => true,
// Check TLD elements
'ipValidator' => null,
]
$tld
protected
null|false|string
$tld
$validIdns
Array for valid Idns
protected
array<string, string|array<int, string>>
$validIdns
= ['AC' => [1 => '/^[\x{002d}0-9a-zà-öø-ÿāăąćĉċčďđēėęěĝġģĥħīįĵķĺļľŀłńņňŋőœŕŗřśŝşšţťŧūŭůűųŵŷźżž]{1,63}$/iu'], 'AR' => [1 => '/^[\x{002d}0-9a-zà-ãç-êìíñ-õü]{1,63}$/iu'], 'AS' => [1 => '/^[\x{002d}0-9a-zà-öø-ÿāăąćĉċčďđēĕėęěĝğġģĥħĩīĭįıĵķĸĺļľłńņňŋōŏőœŕŗřśŝşšţťŧũūŭůűųŵŷźż]{1,63}$/iu'], 'AT' => [1 => '/^[\x{002d}0-9a-zà-öø-ÿœšž]{1,63}$/iu'], 'BIZ' => 'Hostname/Biz.php', 'BR' => [1 => '/^[\x{002d}0-9a-zà-ãçéíó-õúü]{1,63}$/iu'], 'BV' => [1 => '/^[\x{002d}0-9a-zàáä-éêñ-ôöøüčđńŋšŧž]{1,63}$/iu'], 'CAT' => [1 => '/^[\x{002d}0-9a-z·àç-éíïòóúü]{1,63}$/iu'], 'CH' => [1 => '/^[\x{002d}0-9a-zà-öø-ÿœ]{1,63}$/iu'], 'CL' => [1 => '/^[\x{002d}0-9a-záéíñóúü]{1,63}$/iu'], 'CN' => 'Hostname/Cn.php', 'COM' => 'Hostname/Com.php', 'DE' => [1 => '/^[\x{002d}0-9a-záàăâåäãąāæćĉčċçďđéèĕêěëėęēğĝġģĥħíìĭîïĩįīıĵķĺľļłńňñņŋóòŏôöőõøōœĸŕřŗśŝšşßťţŧúùŭûůüűũųūŵýŷÿźžżðþ]{1,63}$/iu'], 'DK' => [1 => '/^[\x{002d}0-9a-zäåæéöøü]{1,63}$/iu'], 'EE' => [1 => '/^[\x{002d}0-9a-zäõöüšž]{1,63}$/iu'], 'ES' => [1 => '/^[\x{002d}0-9a-zàáçèéíïñòóúü·]{1,63}$/iu'], 'EU' => [1 => '/^[\x{002d}0-9a-zà-öø-ÿ]{1,63}$/iu', 2 => '/^[\x{002d}0-9a-zāăąćĉċčďđēĕėęěĝğġģĥħĩīĭįıĵķĺļľŀłńņňʼnŋōŏőœŕŗřśŝšťŧũūŭůűųŵŷźżž]{1,63}$/iu', 3 => '/^[\x{002d}0-9a-zșț]{1,63}$/iu', 4 => '/^[\x{002d}0-9a-zΐάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύώ]{1,63}$/iu', 5 => '/^[\x{002d}0-9a-zабвгдежзийклмнопрстуфхцчшщъыьэюя]{1,63}$/iu', 6 => '/^[\x{002d}0-9a-zἀ-ἇἐ-ἕἠ-ἧἰ-ἷὀ-ὅὐ-ὗὠ-ὧὰ-ὼώᾀ-ᾇᾐ-ᾗᾠ-ᾧᾰ-ᾴᾶᾷῂῃῄῆῇῐ-ῒΐῖῗῠ-ῧῲῳῴῶῷ]{1,63}$/iu'], 'FI' => [1 => '/^[\x{002d}0-9a-zäåö]{1,63}$/iu'], 'GR' => [1 => '/^[\x{002d}0-9a-zΆΈΉΊΌΎ-ΡΣ-ώἀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼῂῃῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲῳῴῶ-ῼ]{1,63}$/iu'], 'HK' => 'Hostname/Cn.php', 'HR' => [1 => '/^[\x{002d}0-9a-zžćčđš]{1,63}$/iu'], 'HU' => [1 => '/^[\x{002d}0-9a-záéíóöúüőű]{1,63}$/iu'], 'IL' => [1 => '/^[\x{002d}0-9\x{05D0}-\x{05EA}]{1,63}$/iu', 2 => '/^[\x{002d}0-9a-z]{1,63}$/i'], 'INFO' => [1 => '/^[\x{002d}0-9a-zäåæéöøü]{1,63}$/iu', 2 => '/^[\x{002d}0-9a-záéíóöúüőű]{1,63}$/iu', 3 => '/^[\x{002d}0-9a-záæéíðóöúýþ]{1,63}$/iu', 4 => '/^[\x{AC00}-\x{D7A3}]{1,17}$/iu', 5 => '/^[\x{002d}0-9a-zāčēģīķļņōŗšūž]{1,63}$/iu', 6 => '/^[\x{002d}0-9a-ząčėęįšūųž]{1,63}$/iu', 7 => '/^[\x{002d}0-9a-zóąćęłńśźż]{1,63}$/iu', 8 => '/^[\x{002d}0-9a-záéíñóúü]{1,63}$/iu'], 'IO' => [1 => '/^[\x{002d}0-9a-zà-öø-ÿăąāćĉčċďđĕěėęēğĝġģĥħĭĩįīıĵķĺľļłńňņŋŏőōœĸŕřŗśŝšşťţŧŭůűũųūŵŷźžż]{1,63}$/iu'], 'IS' => [1 => '/^[\x{002d}0-9a-záéýúíóþæöð]{1,63}$/iu'], 'IT' => [1 => '/^[\x{002d}0-9a-zàâäèéêëìîïòôöùûüæœçÿß-]{1,63}$/iu'], 'JP' => 'Hostname/Jp.php', 'KR' => [1 => '/^[\x{AC00}-\x{D7A3}]{1,17}$/iu'], 'LI' => [1 => '/^[\x{002d}0-9a-zà-öø-ÿœ]{1,63}$/iu'], 'LT' => [1 => '/^[\x{002d}0-9ąčęėįšųūž]{1,63}$/iu'], 'MD' => [1 => '/^[\x{002d}0-9ăâîşţ]{1,63}$/iu'], 'MUSEUM' => [1 => '/^[\x{002d}0-9a-zà-öø-ÿāăąćċčďđēėęěğġģħīįıķĺļľłńņňŋōőœŕŗřśşšţťŧūůűųŵŷźżžǎǐǒǔ\x{01E5}\x{01E7}\x{01E9}\x{01EF}ə\x{0292}ẁẃẅỳ]{1,63}$/iu'], 'NET' => 'Hostname/Com.php', 'NO' => [1 => '/^[\x{002d}0-9a-zàáä-éêñ-ôöøüčđńŋšŧž]{1,63}$/iu'], 'NU' => 'Hostname/Com.php', 'ORG' => [1 => '/^[\x{002d}0-9a-záéíñóúü]{1,63}$/iu', 2 => '/^[\x{002d}0-9a-zóąćęłńśźż]{1,63}$/iu', 3 => '/^[\x{002d}0-9a-záäåæéëíðóöøúüýþ]{1,63}$/iu', 4 => '/^[\x{002d}0-9a-záéíóöúüőű]{1,63}$/iu', 5 => '/^[\x{002d}0-9a-ząčėęįšūųž]{1,63}$/iu', 6 => '/^[\x{AC00}-\x{D7A3}]{1,17}$/iu', 7 => '/^[\x{002d}0-9a-zāčēģīķļņōŗšūž]{1,63}$/iu'], 'PE' => [1 => '/^[\x{002d}0-9a-zñáéíóúü]{1,63}$/iu'], 'PL' => [1 => '/^[\x{002d}0-9a-zāčēģīķļņōŗšūž]{1,63}$/iu', 2 => '/^[\x{002d}а-ик-ш\x{0450}ѓѕјљњќџ]{1,63}$/iu', 3 => '/^[\x{002d}0-9a-zâîăşţ]{1,63}$/iu', 4 => '/^[\x{002d}0-9а-яё\x{04C2}]{1,63}$/iu', 5 => '/^[\x{002d}0-9a-zàáâèéêìíîòóôùúûċġħż]{1,63}$/iu', 6 => '/^[\x{002d}0-9a-zàäåæéêòóôöøü]{1,63}$/iu', 7 => '/^[\x{002d}0-9a-zóąćęłńśźż]{1,63}$/iu', 8 => '/^[\x{002d}0-9a-zàáâãçéêíòóôõúü]{1,63}$/iu', 9 => '/^[\x{002d}0-9a-zâîăşţ]{1,63}$/iu', 10 => '/^[\x{002d}0-9a-záäéíóôúýčďĺľňŕšťž]{1,63}$/iu', 11 => '/^[\x{002d}0-9a-zçë]{1,63}$/iu', 12 => '/^[\x{002d}0-9а-ик-шђјљњћџ]{1,63}$/iu', 13 => '/^[\x{002d}0-9a-zćčđšž]{1,63}$/iu', 14 => '/^[\x{002d}0-9a-zâçöûüğış]{1,63}$/iu', 15 => '/^[\x{002d}0-9a-záéíñóúü]{1,63}$/iu', 16 => '/^[\x{002d}0-9a-zäõöüšž]{1,63}$/iu', 17 => '/^[\x{002d}0-9a-zĉĝĥĵŝŭ]{1,63}$/iu', 18 => '/^[\x{002d}0-9a-zâäéëîô]{1,63}$/iu', 19 => '/^[\x{002d}0-9a-zàáâäåæçèéêëìíîïðñòôöøùúûüýćčłńřśš]{1,63}$/iu', 20 => '/^[\x{002d}0-9a-zäåæõöøüšž]{1,63}$/iu', 21 => '/^[\x{002d}0-9a-zàáçèéìíòóùú]{1,63}$/iu', 22 => '/^[\x{002d}0-9a-zàáéíóöúüőű]{1,63}$/iu', 23 => '/^[\x{002d}0-9ΐά-ώ]{1,63}$/iu', 24 => '/^[\x{002d}0-9a-zàáâåæçèéêëðóôöøüþœ]{1,63}$/iu', 25 => '/^[\x{002d}0-9a-záäéíóöúüýčďěňřšťůž]{1,63}$/iu', 26 => '/^[\x{002d}0-9a-z·àçèéíïòóúü]{1,63}$/iu', 27 => '/^[\x{002d}0-9а-ъьюя\x{0450}\x{045D}]{1,63}$/iu', 28 => '/^[\x{002d}0-9а-яёіў]{1,63}$/iu', 29 => '/^[\x{002d}0-9a-ząčėęįšūųž]{1,63}$/iu', 30 => '/^[\x{002d}0-9a-záäåæéëíðóöøúüýþ]{1,63}$/iu', 31 => '/^[\x{002d}0-9a-zàâæçèéêëîïñôùûüÿœ]{1,63}$/iu', 32 => '/^[\x{002d}0-9а-щъыьэюяёєіїґ]{1,63}$/iu', 33 => '/^[\x{002d}0-9א-ת]{1,63}$/iu'], 'PR' => [1 => '/^[\x{002d}0-9a-záéíóúñäëïüöâêîôûàèùæçœãõ]{1,63}$/iu'], 'PT' => [1 => '/^[\x{002d}0-9a-záàâãçéêíóôõú]{1,63}$/iu'], 'RS' => [1 => '/^[\x{002d}0-9a-zßáâäçéëíîóôöúüýăąćčďđęěĺľłńňőŕřśşšţťůűźżž]{1,63}$/iu'], 'RU' => [1 => '/^[\x{002d}0-9а-яё]{1,63}$/iu'], 'SA' => [1 => '/^[\x{002d}.0-9\x{0621}-\x{063A}\x{0641}-\x{064A}\x{0660}-\x{0669}]{1,63}$/iu'], 'SE' => [1 => '/^[\x{002d}0-9a-zäåéöü]{1,63}$/iu'], 'SH' => [1 => '/^[\x{002d}0-9a-zà-öø-ÿăąāćĉčċďđĕěėęēğĝġģĥħĭĩįīıĵķĺľļłńňņŋŏőōœĸŕřŗśŝšşťţŧŭůűũųūŵŷźžż]{1,63}$/iu'], 'SI' => [1 => '/^[\x{002d}0-9a-zà-öø-ÿ]{1,63}$/iu', 2 => '/^[\x{002d}0-9a-zāăąćĉċčďđēĕėęěĝğġģĥħĩīĭįıĵķĺļľŀłńņňʼnŋōŏőœŕŗřśŝšťŧũūŭůűųŵŷźżž]{1,63}$/iu', 3 => '/^[\x{002d}0-9a-zșț]{1,63}$/iu'], 'SJ' => [1 => '/^[\x{002d}0-9a-zàáä-éêñ-ôöøüčđńŋšŧž]{1,63}$/iu'], 'TH' => [1 => '/^[\x{002d}0-9a-z\x{0E01}-\x{0E3A}\x{0E40}-\x{0E4D}\x{0E50}-\x{0E59}]{1,63}$/iu'], 'TM' => [1 => '/^[\x{002d}0-9a-zà-öø-ÿāăąćĉċčďđēėęěĝġģĥħīįĵķĺļľŀłńņňŋőœŕŗřśŝşšţťŧūŭůűųŵŷźżž]{1,63}$/iu'], 'TW' => 'Hostname/Cn.php', 'TR' => [1 => '/^[\x{002d}0-9a-zğıüşöç]{1,63}$/iu'], 'UA' => [1 => '/^[\x{002d}0-9a-zабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓєѕіїјљњћќѝўџґӂʼ]{1,63}$/iu'], 'VE' => [1 => '/^[\x{002d}0-9a-záéíóúüñ]{1,63}$/iu'], 'VN' => [1 => '/^[ÀÁÂÃÈÉÊÌÍÒÓÔÕÙÚÝàáâãèéêìíòóôõùúýĂăĐđĨĩŨũƠơƯư\x{1EA0}-\x{1EF9}]{1,63}$/iu'], 'мон' => [1 => '/^[\x{002d}0-9\x{0430}-\x{044F}]{1,63}$/iu'], 'срб' => [1 => '/^[\x{002d}0-9а-ик-шђјљњћџ]{1,63}$/iu'], 'сайт' => [1 => '/^[\x{002d}0-9а-яёіїѝйўґг]{1,63}$/iu'], 'онлайн' => [1 => '/^[\x{002d}0-9а-яёіїѝйўґг]{1,63}$/iu'], '中国' => 'Hostname/Cn.php', '中國' => 'Hostname/Cn.php', 'ලංකා' => [1 => '/^[\x{0d80}-\x{0dff}]{1,63}$/iu'], '香港' => 'Hostname/Cn.php', '台湾' => 'Hostname/Cn.php', '台灣' => 'Hostname/Cn.php', 'امارات' => [1 => '/^[\x{0621}-\x{0624}\x{0626}-\x{063A}\x{0641}\x{0642}\x{0644}-\x{0648}\x{067E}\x{0686}\x{0698}\x{06A9}\x{06AF}\x{06CC}\x{06F0}-\x{06F9}]{1,30}$/iu'], 'الاردن' => [1 => '/^[\x{0621}-\x{0624}\x{0626}-\x{063A}\x{0641}\x{0642}\x{0644}-\x{0648}\x{067E}\x{0686}\x{0698}\x{06A9}\x{06AF}\x{06CC}\x{06F0}-\x{06F9}]{1,30}$/iu'], 'السعودية' => [1 => '/^[\x{0621}-\x{0624}\x{0626}-\x{063A}\x{0641}\x{0642}\x{0644}-\x{0648}\x{067E}\x{0686}\x{0698}\x{06A9}\x{06AF}\x{06CC}\x{06F0}-\x{06F9}]{1,30}$/iu'], 'ไทย' => [1 => '/^[\x{002d}0-9a-z\x{0E01}-\x{0E3A}\x{0E40}-\x{0E4D}\x{0E50}-\x{0E59}]{1,63}$/iu'], 'рф' => [1 => '/^[\x{002d}0-9а-яё]{1,63}$/iu'], 'تونس' => [1 => '/^[\x{0621}-\x{0624}\x{0626}-\x{063A}\x{0641}\x{0642}\x{0644}-\x{0648}\x{067E}\x{0686}\x{0698}\x{06A9}\x{06AF}\x{06CC}\x{06F0}-\x{06F9}]{1,30}$/iu'], 'مصر' => [1 => '/^[\x{0621}-\x{0624}\x{0626}-\x{063A}\x{0641}\x{0642}\x{0644}-\x{0648}\x{067E}\x{0686}\x{0698}\x{06A9}\x{06AF}\x{06CC}\x{06F0}-\x{06F9}]{1,30}$/iu'], 'இலங்கை' => [1 => '/^[\x{0b80}-\x{0bff}]{1,63}$/iu'], 'فلسطين' => [1 => '/^[\x{0621}-\x{0624}\x{0626}-\x{063A}\x{0641}\x{0642}\x{0644}-\x{0648}\x{067E}\x{0686}\x{0698}\x{06A9}\x{06AF}\x{06CC}\x{06F0}-\x{06F9}]{1,30}$/iu'], 'شبكة' => [1 => '/^[\x{0621}-\x{0624}\x{0626}-\x{063A}\x{0641}\x{0642}\x{0644}-\x{0648}\x{067E}\x{0686}\x{0698}\x{06A9}\x{06AF}\x{06CC}\x{06F0}-\x{06F9}]{1,30}$/iu']]
Tags
$validTlds
Array of valid top-level-domains IanaVersion 2022072400
protected
array<string|int, string>
$validTlds
= ['aaa', 'aarp', 'abarth', 'abb', 'abbott', 'abbvie', 'abc', 'able', 'abogado', 'abudhabi', 'ac', 'academy', 'accenture', 'accountant', 'accountants', 'aco', 'actor', 'ad', 'adac', 'ads', 'adult', 'ae', 'aeg', 'aero', 'aetna', 'af', 'afl', 'africa', 'ag', 'agakhan', 'agency', 'ai', 'aig', 'airbus', 'airforce', 'airtel', 'akdn', 'al', 'alfaromeo', 'alibaba', 'alipay', 'allfinanz', 'allstate', 'ally', 'alsace', 'alstom', 'am', 'amazon', 'americanexpress', 'americanfamily', 'amex', 'amfam', 'amica', 'amsterdam', 'analytics', 'android', 'anquan', 'anz', 'ao', 'aol', 'apartments', 'app', 'apple', 'aq', 'aquarelle', 'ar', 'arab', 'aramco', 'archi', 'army', 'arpa', 'art', 'arte', 'as', 'asda', 'asia', 'associates', 'at', 'athleta', 'attorney', 'au', 'auction', 'audi', 'audible', 'audio', 'auspost', 'author', 'auto', 'autos', 'avianca', 'aw', 'aws', 'ax', 'axa', 'az', 'azure', 'ba', 'baby', 'baidu', 'banamex', 'bananarepublic', 'band', 'bank', 'bar', 'barcelona', 'barclaycard', 'barclays', 'barefoot', 'bargains', 'baseball', 'basketball', 'bauhaus', 'bayern', 'bb', 'bbc', 'bbt', 'bbva', 'bcg', 'bcn', 'bd', 'be', 'beats', 'beauty', 'beer', 'bentley', 'berlin', 'best', 'bestbuy', 'bet', 'bf', 'bg', 'bh', 'bharti', 'bi', 'bible', 'bid', 'bike', 'bing', 'bingo', 'bio', 'biz', 'bj', 'black', 'blackfriday', 'blockbuster', 'blog', 'bloomberg', 'blue', 'bm', 'bms', 'bmw', 'bn', 'bnpparibas', 'bo', 'boats', 'boehringer', 'bofa', 'bom', 'bond', 'boo', 'book', 'booking', 'bosch', 'bostik', 'boston', 'bot', 'boutique', 'box', 'br', 'bradesco', 'bridgestone', 'broadway', 'broker', 'brother', 'brussels', 'bs', 'bt', 'bugatti', 'build', 'builders', 'business', 'buy', 'buzz', 'bv', 'bw', 'by', 'bz', 'bzh', 'ca', 'cab', 'cafe', 'cal', 'call', 'calvinklein', 'cam', 'camera', 'camp', 'cancerresearch', 'canon', 'capetown', 'capital', 'capitalone', 'car', 'caravan', 'cards', 'care', 'career', 'careers', 'cars', 'casa', 'case', 'cash', 'casino', 'cat', 'catering', 'catholic', 'cba', 'cbn', 'cbre', 'cbs', 'cc', 'cd', 'center', 'ceo', 'cern', 'cf', 'cfa', 'cfd', 'cg', 'ch', 'chanel', 'channel', 'charity', 'chase', 'chat', 'cheap', 'chintai', 'christmas', 'chrome', 'church', 'ci', 'cipriani', 'circle', 'cisco', 'citadel', 'citi', 'citic', 'city', 'cityeats', 'ck', 'cl', 'claims', 'cleaning', 'click', 'clinic', 'clinique', 'clothing', 'cloud', 'club', 'clubmed', 'cm', 'cn', 'co', 'coach', 'codes', 'coffee', 'college', 'cologne', 'com', 'comcast', 'commbank', 'community', 'company', 'compare', 'computer', 'comsec', 'condos', 'construction', 'consulting', 'contact', 'contractors', 'cooking', 'cookingchannel', 'cool', 'coop', 'corsica', 'country', 'coupon', 'coupons', 'courses', 'cpa', 'cr', 'credit', 'creditcard', 'creditunion', 'cricket', 'crown', 'crs', 'cruise', 'cruises', 'cu', 'cuisinella', 'cv', 'cw', 'cx', 'cy', 'cymru', 'cyou', 'cz', 'dabur', 'dad', 'dance', 'data', 'date', 'dating', 'datsun', 'day', 'dclk', 'dds', 'de', 'deal', 'dealer', 'deals', 'degree', 'delivery', 'dell', 'deloitte', 'delta', 'democrat', 'dental', 'dentist', 'desi', 'design', 'dev', 'dhl', 'diamonds', 'diet', 'digital', 'direct', 'directory', 'discount', 'discover', 'dish', 'diy', 'dj', 'dk', 'dm', 'dnp', 'do', 'docs', 'doctor', 'dog', 'domains', 'dot', 'download', 'drive', 'dtv', 'dubai', 'dunlop', 'dupont', 'durban', 'dvag', 'dvr', 'dz', 'earth', 'eat', 'ec', 'eco', 'edeka', 'edu', 'education', 'ee', 'eg', 'email', 'emerck', 'energy', 'engineer', 'engineering', 'enterprises', 'epson', 'equipment', 'er', 'ericsson', 'erni', 'es', 'esq', 'estate', 'et', 'etisalat', 'eu', 'eurovision', 'eus', 'events', 'exchange', 'expert', 'exposed', 'express', 'extraspace', 'fage', 'fail', 'fairwinds', 'faith', 'family', 'fan', 'fans', 'farm', 'farmers', 'fashion', 'fast', 'fedex', 'feedback', 'ferrari', 'ferrero', 'fi', 'fiat', 'fidelity', 'fido', 'film', 'final', 'finance', 'financial', 'fire', 'firestone', 'firmdale', 'fish', 'fishing', 'fit', 'fitness', 'fj', 'fk', 'flickr', 'flights', 'flir', 'florist', 'flowers', 'fly', 'fm', 'fo', 'foo', 'food', 'foodnetwork', 'football', 'ford', 'forex', 'forsale', 'forum', 'foundation', 'fox', 'fr', 'free', 'fresenius', 'frl', 'frogans', 'frontdoor', 'frontier', 'ftr', 'fujitsu', 'fun', 'fund', 'furniture', 'futbol', 'fyi', 'ga', 'gal', 'gallery', 'gallo', 'gallup', 'game', 'games', 'gap', 'garden', 'gay', 'gb', 'gbiz', 'gd', 'gdn', 'ge', 'gea', 'gent', 'genting', 'george', 'gf', 'gg', 'ggee', 'gh', 'gi', 'gift', 'gifts', 'gives', 'giving', 'gl', 'glass', 'gle', 'global', 'globo', 'gm', 'gmail', 'gmbh', 'gmo', 'gmx', 'gn', 'godaddy', 'gold', 'goldpoint', 'golf', 'goo', 'goodyear', 'goog', 'google', 'gop', 'got', 'gov', 'gp', 'gq', 'gr', 'grainger', 'graphics', 'gratis', 'green', 'gripe', 'grocery', 'group', 'gs', 'gt', 'gu', 'guardian', 'gucci', 'guge', 'guide', 'guitars', 'guru', 'gw', 'gy', 'hair', 'hamburg', 'hangout', 'haus', 'hbo', 'hdfc', 'hdfcbank', 'health', 'healthcare', 'help', 'helsinki', 'here', 'hermes', 'hgtv', 'hiphop', 'hisamitsu', 'hitachi', 'hiv', 'hk', 'hkt', 'hm', 'hn', 'hockey', 'holdings', 'holiday', 'homedepot', 'homegoods', 'homes', 'homesense', 'honda', 'horse', 'hospital', 'host', 'hosting', 'hot', 'hoteles', 'hotels', 'hotmail', 'house', 'how', 'hr', 'hsbc', 'ht', 'hu', 'hughes', 'hyatt', 'hyundai', 'ibm', 'icbc', 'ice', 'icu', 'id', 'ie', 'ieee', 'ifm', 'ikano', 'il', 'im', 'imamat', 'imdb', 'immo', 'immobilien', 'in', 'inc', 'industries', 'infiniti', 'info', 'ing', 'ink', 'institute', 'insurance', 'insure', 'int', 'international', 'intuit', 'investments', 'io', 'ipiranga', 'iq', 'ir', 'irish', 'is', 'ismaili', 'ist', 'istanbul', 'it', 'itau', 'itv', 'jaguar', 'java', 'jcb', 'je', 'jeep', 'jetzt', 'jewelry', 'jio', 'jll', 'jm', 'jmp', 'jnj', 'jo', 'jobs', 'joburg', 'jot', 'joy', 'jp', 'jpmorgan', 'jprs', 'juegos', 'juniper', 'kaufen', 'kddi', 'ke', 'kerryhotels', 'kerrylogistics', 'kerryproperties', 'kfh', 'kg', 'kh', 'ki', 'kia', 'kids', 'kim', 'kinder', 'kindle', 'kitchen', 'kiwi', 'km', 'kn', 'koeln', 'komatsu', 'kosher', 'kp', 'kpmg', 'kpn', 'kr', 'krd', 'kred', 'kuokgroup', 'kw', 'ky', 'kyoto', 'kz', 'la', 'lacaixa', 'lamborghini', 'lamer', 'lancaster', 'lancia', 'land', 'landrover', 'lanxess', 'lasalle', 'lat', 'latino', 'latrobe', 'law', 'lawyer', 'lb', 'lc', 'lds', 'lease', 'leclerc', 'lefrak', 'legal', 'lego', 'lexus', 'lgbt', 'li', 'lidl', 'life', 'lifeinsurance', 'lifestyle', 'lighting', 'like', 'lilly', 'limited', 'limo', 'lincoln', 'linde', 'link', 'lipsy', 'live', 'living', 'lk', 'llc', 'llp', 'loan', 'loans', 'locker', 'locus', 'loft', 'lol', 'london', 'lotte', 'lotto', 'love', 'lpl', 'lplfinancial', 'lr', 'ls', 'lt', 'ltd', 'ltda', 'lu', 'lundbeck', 'luxe', 'luxury', 'lv', 'ly', 'ma', 'macys', 'madrid', 'maif', 'maison', 'makeup', 'man', 'management', 'mango', 'map', 'market', 'marketing', 'markets', 'marriott', 'marshalls', 'maserati', 'mattel', 'mba', 'mc', 'mckinsey', 'md', 'me', 'med', 'media', 'meet', 'melbourne', 'meme', 'memorial', 'men', 'menu', 'merckmsd', 'mg', 'mh', 'miami', 'microsoft', 'mil', 'mini', 'mint', 'mit', 'mitsubishi', 'mk', 'ml', 'mlb', 'mls', 'mm', 'mma', 'mn', 'mo', 'mobi', 'mobile', 'moda', 'moe', 'moi', 'mom', 'monash', 'money', 'monster', 'mormon', 'mortgage', 'moscow', 'moto', 'motorcycles', 'mov', 'movie', 'mp', 'mq', 'mr', 'ms', 'msd', 'mt', 'mtn', 'mtr', 'mu', 'museum', 'music', 'mutual', 'mv', 'mw', 'mx', 'my', 'mz', 'na', 'nab', 'nagoya', 'name', 'natura', 'navy', 'nba', 'nc', 'ne', 'nec', 'net', 'netbank', 'netflix', 'network', 'neustar', 'new', 'news', 'next', 'nextdirect', 'nexus', 'nf', 'nfl', 'ng', 'ngo', 'nhk', 'ni', 'nico', 'nike', 'nikon', 'ninja', 'nissan', 'nissay', 'nl', 'no', 'nokia', 'northwesternmutual', 'norton', 'now', 'nowruz', 'nowtv', 'np', 'nr', 'nra', 'nrw', 'ntt', 'nu', 'nyc', 'nz', 'obi', 'observer', 'office', 'okinawa', 'olayan', 'olayangroup', 'oldnavy', 'ollo', 'om', 'omega', 'one', 'ong', 'onl', 'online', 'ooo', 'open', 'oracle', 'orange', 'org', 'organic', 'origins', 'osaka', 'otsuka', 'ott', 'ovh', 'pa', 'page', 'panasonic', 'paris', 'pars', 'partners', 'parts', 'party', 'passagens', 'pay', 'pccw', 'pe', 'pet', 'pf', 'pfizer', 'pg', 'ph', 'pharmacy', 'phd', 'philips', 'phone', 'photo', 'photography', 'photos', 'physio', 'pics', 'pictet', 'pictures', 'pid', 'pin', 'ping', 'pink', 'pioneer', 'pizza', 'pk', 'pl', 'place', 'play', 'playstation', 'plumbing', 'plus', 'pm', 'pn', 'pnc', 'pohl', 'poker', 'politie', 'porn', 'post', 'pr', 'pramerica', 'praxi', 'press', 'prime', 'pro', 'prod', 'productions', 'prof', 'progressive', 'promo', 'properties', 'property', 'protection', 'pru', 'prudential', 'ps', 'pt', 'pub', 'pw', 'pwc', 'py', 'qa', 'qpon', 'quebec', 'quest', 'racing', 'radio', 're', 'read', 'realestate', 'realtor', 'realty', 'recipes', 'red', 'redstone', 'redumbrella', 'rehab', 'reise', 'reisen', 'reit', 'reliance', 'ren', 'rent', 'rentals', 'repair', 'report', 'republican', 'rest', 'restaurant', 'review', 'reviews', 'rexroth', 'rich', 'richardli', 'ricoh', 'ril', 'rio', 'rip', 'ro', 'rocher', 'rocks', 'rodeo', 'rogers', 'room', 'rs', 'rsvp', 'ru', 'rugby', 'ruhr', 'run', 'rw', 'rwe', 'ryukyu', 'sa', 'saarland', 'safe', 'safety', 'sakura', 'sale', 'salon', 'samsclub', 'samsung', 'sandvik', 'sandvikcoromant', 'sanofi', 'sap', 'sarl', 'sas', 'save', 'saxo', 'sb', 'sbi', 'sbs', 'sc', 'sca', 'scb', 'schaeffler', 'schmidt', 'scholarships', 'school', 'schule', 'schwarz', 'science', 'scot', 'sd', 'se', 'search', 'seat', 'secure', 'security', 'seek', 'select', 'sener', 'services', 'ses', 'seven', 'sew', 'sex', 'sexy', 'sfr', 'sg', 'sh', 'shangrila', 'sharp', 'shaw', 'shell', 'shia', 'shiksha', 'shoes', 'shop', 'shopping', 'shouji', 'show', 'showtime', 'si', 'silk', 'sina', 'singles', 'site', 'sj', 'sk', 'ski', 'skin', 'sky', 'skype', 'sl', 'sling', 'sm', 'smart', 'smile', 'sn', 'sncf', 'so', 'soccer', 'social', 'softbank', 'software', 'sohu', 'solar', 'solutions', 'song', 'sony', 'soy', 'spa', 'space', 'sport', 'spot', 'sr', 'srl', 'ss', 'st', 'stada', 'staples', 'star', 'statebank', 'statefarm', 'stc', 'stcgroup', 'stockholm', 'storage', 'store', 'stream', 'studio', 'study', 'style', 'su', 'sucks', 'supplies', 'supply', 'support', 'surf', 'surgery', 'suzuki', 'sv', 'swatch', 'swiss', 'sx', 'sy', 'sydney', 'systems', 'sz', 'tab', 'taipei', 'talk', 'taobao', 'target', 'tatamotors', 'tatar', 'tattoo', 'tax', 'taxi', 'tc', 'tci', 'td', 'tdk', 'team', 'tech', 'technology', 'tel', 'temasek', 'tennis', 'teva', 'tf', 'tg', 'th', 'thd', 'theater', 'theatre', 'tiaa', 'tickets', 'tienda', 'tiffany', 'tips', 'tires', 'tirol', 'tj', 'tjmaxx', 'tjx', 'tk', 'tkmaxx', 'tl', 'tm', 'tmall', 'tn', 'to', 'today', 'tokyo', 'tools', 'top', 'toray', 'toshiba', 'total', 'tours', 'town', 'toyota', 'toys', 'tr', 'trade', 'trading', 'training', 'travel', 'travelchannel', 'travelers', 'travelersinsurance', 'trust', 'trv', 'tt', 'tube', 'tui', 'tunes', 'tushu', 'tv', 'tvs', 'tw', 'tz', 'ua', 'ubank', 'ubs', 'ug', 'uk', 'unicom', 'university', 'uno', 'uol', 'ups', 'us', 'uy', 'uz', 'va', 'vacations', 'vana', 'vanguard', 'vc', 've', 'vegas', 'ventures', 'verisign', 'versicherung', 'vet', 'vg', 'vi', 'viajes', 'video', 'vig', 'viking', 'villas', 'vin', 'vip', 'virgin', 'visa', 'vision', 'viva', 'vivo', 'vlaanderen', 'vn', 'vodka', 'volkswagen', 'volvo', 'vote', 'voting', 'voto', 'voyage', 'vu', 'vuelos', 'wales', 'walmart', 'walter', 'wang', 'wanggou', 'watch', 'watches', 'weather', 'weatherchannel', 'webcam', 'weber', 'website', 'wed', 'wedding', 'weibo', 'weir', 'wf', 'whoswho', 'wien', 'wiki', 'williamhill', 'win', 'windows', 'wine', 'winners', 'wme', 'wolterskluwer', 'woodside', 'work', 'works', 'world', 'wow', 'ws', 'wtc', 'wtf', 'xbox', 'xerox', 'xfinity', 'xihuan', 'xin', 'कॉम', 'セール', '佛山', 'ಭಾರತ', '慈善', '集团', '在线', '한국', 'ଭାରତ', '点看', 'คอม', 'ভাৰত', 'ভারত', '八卦', 'ישראל', 'موقع', 'বাংলা', '公益', '公司', '香格里拉', '网站', '移动', '我爱你', 'москва', 'қаз', 'католик', 'онлайн', 'сайт', '联通', 'срб', 'бг', 'бел', 'קום', '时尚', '微博', '淡马锡', 'ファッション', 'орг', 'नेट', 'ストア', 'アマゾン', '삼성', 'சிங்கப்பூர்', '商标', '商店', '商城', 'дети', 'мкд', 'ею', 'ポイント', '新闻', '家電', 'كوم', '中文网', '中信', '中国', '中國', '娱乐', '谷歌', 'భారత్', 'ලංකා', '電訊盈科', '购物', 'クラウド', 'ભારત', '通販', 'भारतम्', 'भारत', 'भारोत', '网店', 'संगठन', '餐厅', '网络', 'ком', 'укр', '香港', '亚马逊', '诺基亚', '食品', '飞利浦', '台湾', '台灣', '手机', 'мон', 'الجزائر', 'عمان', 'ارامكو', 'ایران', 'العليان', 'اتصالات', 'امارات', 'بازار', 'موريتانيا', 'پاکستان', 'الاردن', 'بارت', 'بھارت', 'المغرب', 'ابوظبي', 'البحرين', 'السعودية', 'ڀارت', 'كاثوليك', 'سودان', 'همراه', 'عراق', 'مليسيا', '澳門', '닷컴', '政府', 'شبكة', 'بيتك', 'عرب', 'გე', '机构', '组织机构', '健康', 'ไทย', 'سورية', '招聘', 'рус', 'рф', 'تونس', '大拿', 'ລາວ', 'みんな', 'グーグル', 'ευ', 'ελ', '世界', '書籍', 'ഭാരതം', 'ਭਾਰਤ', '网址', '닷넷', 'コム', '天主教', '游戏', 'vermögensberater', 'vermögensberatung', '企业', '信息', '嘉里大酒店', '嘉里', 'مصر', 'قطر', '广东', 'இலங்கை', 'இந்தியா', 'հայ', '新加坡', 'فلسطين', '政务', 'xxx', 'xyz', 'yachts', 'yahoo', 'yamaxun', 'yandex', 'ye', 'yodobashi', 'yoga', 'yokohama', 'you', 'youtube', 'yt', 'yun', 'za', 'zappos', 'zara', 'zero', 'zip', 'zm', 'zone', 'zuerich', 'zw']
Tags
$value
The value to be validated
protected
mixed
$value
Methods
__construct()
Sets validator options.
public
__construct([array<string|int, mixed> $options = [] ]) : mixed
Parameters
- $options : array<string|int, mixed> = []
-
OPTIONAL Array of validator options; see Hostname::$options
Tags
__get()
Magic function returns the value of the requested property, if and only if it is the value or a message variable.
public
__get(string $property) : mixed
Parameters
- $property : string
Tags
__invoke()
Invoke as command
public
__invoke(mixed $value) : bool
Parameters
- $value : mixed
Return values
boolgetAllow()
Returns the allow option
public
getAllow() : int
Return values
intgetDefaultTranslator()
Get default translation object for all validate objects
public
static getDefaultTranslator() : TranslatorInterface|null
Return values
TranslatorInterface|nullgetDefaultTranslatorTextDomain()
Get default translation text domain for all validate objects
public
static getDefaultTranslatorTextDomain() : string
Return values
stringgetIdnCheck()
Returns the set idn option
public
getIdnCheck() : bool
Return values
boolgetIpValidator()
Returns the set ip validator
public
getIpValidator() : Ip
Return values
IpgetMessageLength()
Returns the maximum allowed message length
public
static getMessageLength() : int
Return values
intgetMessages()
Returns array of validation failure messages
public
getMessages() : array<string, string>
Return values
array<string, string>getMessageTemplates()
Returns the message templates from the validator
public
getMessageTemplates() : array<string, string>
Return values
array<string, string>getMessageVariables()
Returns an array of the names of variables that are used in constructing validation failure messages
public
getMessageVariables() : array<int, string>
Return values
array<int, string>getOption()
Returns an option
public
getOption(string $option) : mixed
Parameters
- $option : string
-
Option to be returned
Tags
Return values
mixed —Returned option
getOptions()
Returns all available options
public
getOptions() : array<string, mixed>
Return values
array<string, mixed> —Array with all available options
getTldCheck()
Returns the set tld option
public
getTldCheck() : bool
Return values
boolgetTranslator()
Return translation object
public
getTranslator() : TranslatorInterface|null
Return values
TranslatorInterface|nullgetTranslatorTextDomain()
Return the translation text domain
public
getTranslatorTextDomain() : string
Return values
stringhasDefaultTranslator()
Is there a default translation object set?
public
static hasDefaultTranslator() : bool
Return values
boolhasTranslator()
Does this validator have its own specific translator?
public
hasTranslator() : bool
Return values
boolisTranslatorEnabled()
Is translation enabled?
public
isTranslatorEnabled() : bool
Return values
boolisValid()
Defined by Interface
public
isValid(string $value) : bool
Returns true if and only if the $value is a valid hostname with respect to the current allow option
Parameters
- $value : string
Return values
boolisValueObscured()
Retrieve flag indicating whether or not value should be obfuscated in messages
public
isValueObscured() : bool
Return values
boolsetAllow()
Sets the allow option
public
setAllow(int $allow) : $this
Parameters
- $allow : int
Return values
$this —Provides a fluent interface
setDefaultTranslator()
Set default translation object for all validate objects
public
static setDefaultTranslator([TranslatorInterface|null $translator = null ][, string $textDomain = null ]) : void
Parameters
- $translator : TranslatorInterface|null = null
- $textDomain : string = null
-
(optional)
Tags
setDefaultTranslatorTextDomain()
Set default translation text domain for all validate objects
public
static setDefaultTranslatorTextDomain([string $textDomain = 'default' ]) : void
Parameters
- $textDomain : string = 'default'
setIpValidator()
public
setIpValidator([Ip $ipValidator = null ]) : self
Parameters
- $ipValidator : Ip = null
-
OPTIONAL
Return values
selfsetMessage()
Sets the validation failure message template for a particular key
public
setMessage(string $messageString[, string|null $messageKey = null ]) : $this
Parameters
- $messageString : string
- $messageKey : string|null = null
-
OPTIONAL
Tags
Return values
$this —Provides a fluent interface
setMessageLength()
Sets the maximum allowed message length
public
static setMessageLength([int $length = -1 ]) : void
Parameters
- $length : int = -1
setMessages()
Sets validation failure message templates given as an array, where the array keys are the message keys, and the array values are the message template strings.
public
setMessages(array<string, string> $messages) : $this
Parameters
- $messages : array<string, string>
Return values
$thissetOptions()
Sets one or multiple options
public
setOptions([array<string, mixed>|Traversable<string, mixed> $options = [] ]) : $this
Parameters
- $options : array<string, mixed>|Traversable<string, mixed> = []
-
Options to set
Tags
Return values
$this —Provides fluid interface
setTranslator()
Set translation object
public
setTranslator([TranslatorInterface|null $translator = null ][, string $textDomain = null ]) : $this
Parameters
- $translator : TranslatorInterface|null = null
-
[optional] translator. Default is null, which sets no translator.
- $textDomain : string = null
-
(optional)
Tags
Return values
$thissetTranslatorEnabled()
Indicate whether or not translation should be enabled
public
setTranslatorEnabled([bool $enabled = true ]) : $this
Parameters
- $enabled : bool = true
Return values
$thissetTranslatorTextDomain()
Set translation text domain
public
setTranslatorTextDomain([string $textDomain = 'default' ]) : $this
Parameters
- $textDomain : string = 'default'
Return values
$thissetValueObscured()
Set flag indicating whether or not value should be obfuscated in messages
public
setValueObscured(bool $flag) : $this
Parameters
- $flag : bool
Return values
$thisuseIdnCheck()
Set whether IDN domains are validated
public
useIdnCheck(bool $useIdnCheck) : $this
This only applies when DNS hostnames are validated
Parameters
- $useIdnCheck : bool
-
Set to true to validate IDN domains
Return values
$thisuseTldCheck()
Set whether the TLD element of a hostname is validated
public
useTldCheck(bool $useTldCheck) : $this
This only applies when DNS hostnames are validated
Parameters
- $useTldCheck : bool
-
Set to true to validate TLD elements
Return values
$thiscreateMessage()
Constructs and returns a validation failure message with the given message key and value.
protected
createMessage(string $messageKey, string|array<string|int, mixed>|object $value) : null|string
Returns null if and only if $messageKey does not correspond to an existing template.
If a translator is available and a translation exists for $messageKey, the translation will be used.
Parameters
- $messageKey : string
- $value : string|array<string|int, mixed>|object
Return values
null|stringdecodePunycode()
Decodes a punycode encoded string to it's original utf8 string Returns false in case of a decoding failure.
protected
decodePunycode(string $encoded) : string|false
Parameters
- $encoded : string
-
Punycode encoded string to decode
Return values
string|falseerror()
protected
error(string|null $messageKey[, null|string|array<string|int, mixed>|object $value = null ]) : void
Parameters
- $messageKey : string|null
- $value : null|string|array<string|int, mixed>|object = null
-
OPTIONAL
getValue()
Returns the validation value
protected
getValue() : mixed
Return values
mixed —Value to be validated
setValue()
Sets the value to be validated and clears the messages and errors arrays
protected
setValue(mixed $value) : void
Parameters
- $value : mixed
translateMessage()
Translate a validation message
protected
translateMessage(string $messageKey, string $message) : string
Parameters
- $messageKey : string
- $message : string