Zend Framework
2.4
|
Please note there are two standalone test scripts for testing IDN characters due to problems with file encoding. More...
Public Member Functions | |
__construct ($options=array()) | |
Sets validator options. | |
getIpValidator () | |
Returns the set ip validator. | |
setIpValidator (Ip $ipValidator=null) | |
getAllow () | |
Returns the allow option. | |
setAllow ($allow) | |
Sets the allow option. | |
getIdnCheck () | |
Returns the set idn option. | |
useIdnCheck ($useIdnCheck) | |
Set whether IDN domains are validated. | |
getTldCheck () | |
Returns the set tld option. | |
useTldCheck ($useTldCheck) | |
Set whether the TLD element of a hostname is validated. | |
isValid ($value) | |
Defined by Interface. | |
![]() | |
__construct ($options=null) | |
Abstract constructor for all validators A validator should accept following parameters: | |
getOption ($option) | |
Returns an option. | |
getOptions () | |
Returns all available options. | |
setOptions ($options=array()) | |
Sets one or multiple options. | |
getMessages () | |
Returns array of validation failure messages. | |
__invoke ($value) | |
Invoke as command. | |
getMessageVariables () | |
Returns an array of the names of variables that are used in constructing validation failure messages. | |
getMessageTemplates () | |
Returns the message templates from the validator. | |
setMessage ($messageString, $messageKey=null) | |
Sets the validation failure message template for a particular key. | |
setMessages (array $messages) | |
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. | |
__get ($property) | |
Magic function returns the value of the requested property, if and only if it is the value or a message variable. | |
setValueObscured ($flag) | |
Set flag indicating whether or not value should be obfuscated in messages. | |
isValueObscured () | |
Retrieve flag indicating whether or not value should be obfuscated in messages. | |
setTranslator (Translator\TranslatorInterface $translator=null, $textDomain=null) | |
Set translation object. | |
getTranslator () | |
Return translation object. | |
hasTranslator () | |
Does this validator have its own specific translator? | |
setTranslatorTextDomain ($textDomain= 'default') | |
Set translation text domain. | |
getTranslatorTextDomain () | |
Return the translation text domain. | |
setTranslatorEnabled ($flag=true) | |
Indicate whether or not translation should be enabled. | |
isTranslatorEnabled () | |
Is translation enabled? | |
![]() | |
setTranslator (TranslatorInterface $translator=null, $textDomain=null) | |
Sets translator to use in helper. | |
Public Attributes | |
const | CANNOT_DECODE_PUNYCODE = 'hostnameCannotDecodePunycode' |
const | INVALID = 'hostnameInvalid' |
const | INVALID_DASH = 'hostnameDashCharacter' |
const | INVALID_HOSTNAME = 'hostnameInvalidHostname' |
const | INVALID_HOSTNAME_SCHEMA = 'hostnameInvalidHostnameSchema' |
const | INVALID_LOCAL_NAME = 'hostnameInvalidLocalName' |
const | INVALID_URI = 'hostnameInvalidUri' |
const | IP_ADDRESS_NOT_ALLOWED = 'hostnameIpAddressNotAllowed' |
const | LOCAL_NAME_NOT_ALLOWED = 'hostnameLocalNameNotAllowed' |
const | UNDECIPHERABLE_TLD = 'hostnameUndecipherableTld' |
const | UNKNOWN_TLD = 'hostnameUnknownTld' |
const | ALLOW_DNS = 1 |
const | ALLOW_IP = 2 |
const | ALLOW_LOCAL = 4 |
const | ALLOW_URI = 8 |
const | ALLOW_ALL = 15 |
Protected Member Functions | |
decodePunycode ($encoded) | |
Decodes a punycode encoded string to it's original utf8 string Returns false in case of a decoding failure. | |
![]() | |
createMessage ($messageKey, $value) | |
Constructs and returns a validation failure message with the given message key and value. | |
error ($messageKey, $value=null) | |
getValue () | |
Returns the validation value. | |
setValue ($value) | |
Sets the value to be validated and clears the messages and errors arrays. | |
translateMessage ($messageKey, $message) | |
Translate a validation message. | |
Protected Attributes | |
$messageTemplates | |
$messageVariables | |
$validTlds | |
$validIdns | |
$idnLength | |
$tld | |
$options | |
![]() | |
$value | |
$abstractOptions | |
Additional Inherited Members | |
![]() | |
static | setDefaultTranslator (Translator\TranslatorInterface $translator=null, $textDomain=null) |
Set default translation object for all validate objects. | |
static | getDefaultTranslator () |
Get default translation object for all validate objects. | |
static | hasDefaultTranslator () |
Is there a default translation object set? | |
static | setDefaultTranslatorTextDomain ($textDomain= 'default') |
Set default translation text domain for all validate objects. | |
static | getDefaultTranslatorTextDomain () |
Get default translation text domain for all validate objects. | |
static | getMessageLength () |
Returns the maximum allowed message length. | |
static | setMessageLength ($length=-1) |
Sets the maximum allowed message length. | |
![]() | |
static | $defaultTranslator |
static | $defaultTranslatorTextDomain = 'default' |
static | $messageLength = -1 |
Please note there are two standalone test scripts for testing IDN characters due to problems with file encoding.
The first is tests/Zend/Validator/HostnameTestStandalone.php which is designed to be run on the command line.
The second is tests/Zend/Validator/HostnameTestForm.php which is designed to be run via HTML to allow users to test entering UTF-8 characters in a form.
__construct | ( | $options = array() | ) |
Sets validator options.
int | $allow | OPTIONAL Set what types of hostname to allow (default ALLOW_DNS) |
bool | $useIdnCheck | OPTIONAL Set whether IDN domains are validated (default true) |
bool | $useTldCheck | Set whether the TLD element of a hostname is validated (default true) |
Ip | $ipValidator | OPTIONAL |
|
protected |
Decodes a punycode encoded string to it's original utf8 string Returns false in case of a decoding failure.
string | $encoded | Punycode encoded string to decode |
getAllow | ( | ) |
Returns the allow option.
getIdnCheck | ( | ) |
Returns the set idn option.
getIpValidator | ( | ) |
Returns the set ip validator.
getTldCheck | ( | ) |
Returns the set tld option.
isValid | ( | $value | ) |
Defined by Interface.
Returns true if and only if the $value is a valid hostname with respect to the current allow option
string | $value |
Match against IDN hostnames Note: Keep label regex short to avoid issues with long patterns when matching IDN hostnames
Implements ValidatorInterface.
setAllow | ( | $allow | ) |
useIdnCheck | ( | $useIdnCheck | ) |
Set whether IDN domains are validated.
This only applies when DNS hostnames are validated
bool | $useIdnCheck | Set to true to validate IDN domains |
useTldCheck | ( | $useTldCheck | ) |
Set whether the TLD element of a hostname is validated.
This only applies when DNS hostnames are validated
bool | $useTldCheck | Set to true to validate TLD elements |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
const ALLOW_ALL = 15 |
const ALLOW_DNS = 1 |
const ALLOW_IP = 2 |
const ALLOW_LOCAL = 4 |
const ALLOW_URI = 8 |
const CANNOT_DECODE_PUNYCODE = 'hostnameCannotDecodePunycode' |
const INVALID = 'hostnameInvalid' |
const INVALID_DASH = 'hostnameDashCharacter' |
const INVALID_HOSTNAME = 'hostnameInvalidHostname' |
const INVALID_HOSTNAME_SCHEMA = 'hostnameInvalidHostnameSchema' |
const INVALID_LOCAL_NAME = 'hostnameInvalidLocalName' |
const INVALID_URI = 'hostnameInvalidUri' |
const IP_ADDRESS_NOT_ALLOWED = 'hostnameIpAddressNotAllowed' |
const LOCAL_NAME_NOT_ALLOWED = 'hostnameLocalNameNotAllowed' |
const UNDECIPHERABLE_TLD = 'hostnameUndecipherableTld' |
const UNKNOWN_TLD = 'hostnameUnknownTld' |