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.
Methods
Sets validator options.
__construct($options)
Validator()
- one or multiple scalar values f.e. Validator($first, $second, $third)
- an array f.e. Validator(array($first => 'first', $second => 'second', $third => 'third'))
- an instance of Traversable f.e. Validator($config_instance)
see |
\Zend\Validator\http://www.iana.org/cctld/specifications-policies-cctlds-01apr02.htm |
Parameters
$options
Magic function returns the value of the requested property, if and only if it is the value or a
message variable.
__get(string $property) : mixed
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::__get() |
Parameters
$property
string
Exceptions
Returns
mixed
Invoke as command
__invoke(mixed $value) : bool
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::__invoke() |
Parameters
$value
mixed
Returns
bool
Returns the allow option
getAllow() : int
Get default translation text domain for all validate objects
getDefaultTranslatorTextDomain() : string
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::getDefaultTranslatorTextDomain() |
Returns
string
Returns the set idn option
getIdnCheck() : bool
Returns the maximum allowed message length
getMessageLength() : int
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::getMessageLength() |
Returns
int
Returns the message templates from the validator
getMessageTemplates() : array
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::getMessageTemplates() |
Returns
array
Returns an array of the names of variables that are used in constructing validation failure messages
getMessageVariables() : array
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::getMessageVariables() |
Returns
array
Returns array of validation failure messages
getMessages() : array
Inherited
The array keys are validation failure message identifiers,
and the array values are the corresponding human-readable message strings.
If isValid() was never called or if the most recent isValid() call
returned true, then this method returns an empty array.
inherited_from |
\Zend\Validator\AbstractValidator::getMessages() |
Returns
array
Returns an option
getOption(string $option) : mixed
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::getOption() |
Parameters
$option
string
Option to be returned
Exceptions
Returns
mixed
Returned option
Returns all available options
getOptions() : array
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::getOptions() |
Returns
array
Array with all available options
Returns the set tld option
getTldCheck() : bool
Return the translation text domain
getTranslatorTextDomain() : string
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::getTranslatorTextDomain() |
Returns
string
Is there a default translation object set?
hasDefaultTranslator() : bool
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::hasDefaultTranslator() |
Returns
bool
Does this validator have its own specific translator?
hasTranslator() : bool
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::hasTranslator() |
Returns
bool
Is translation enabled?
isTranslatorEnabled() : bool
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::isTranslatorEnabled() |
Returns
bool
Defined by Interface
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
Exceptions
Returns
bool
Retrieve flag indicating whether or not value should be obfuscated in
messages
isValueObscured() : bool
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::isValueObscured() |
Returns
bool
Set default translation object for all validate objects
setDefaultTranslator(\Zend\Validator\Translator\TranslatorInterface $translator, string $textDomain) : void
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::setDefaultTranslator() |
Parameters
$textDomain
string
(optional)
Exceptions
Set default translation text domain for all validate objects
setDefaultTranslatorTextDomain(string $textDomain) : void
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::setDefaultTranslatorTextDomain() |
Parameters
$textDomain
string
setIpValidator()
setIpValidator(\Zend\Validator\Ip $ipValidator) : \Zend\Validator\Hostname;
Parameters
Returns
\Zend\Validator\Hostname;
Sets the validation failure message template for a particular key
setMessage(string $messageString, string $messageKey) : \Zend\Validator\AbstractValidator
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::setMessage() |
Parameters
$messageString
string
$messageKey
string
OPTIONAL
Exceptions
Returns
Sets the maximum allowed message length
setMessageLength(int $length)
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::setMessageLength() |
Parameters
$length
int
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.
setMessages(array $messages) : \Zend\Validator\AbstractValidator
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::setMessages() |
Parameters
$messages
array
Returns
Sets one or multiple options
setOptions(array | \Traversable $options) : \Zend\Validator\AbstractValidator
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::setOptions() |
Parameters
$options
array\Traversable
Options to set
Exceptions
Returns
Set translation object
setTranslator(\Zend\Validator\Translator\TranslatorInterface $translator, string $textDomain) : \Zend\Validator\AbstractValidator
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::setTranslator() |
Parameters
$textDomain
string
(optional)
Exceptions
Returns
Indicate whether or not translation should be enabled
setTranslatorEnabled(bool $flag) : \Zend\Validator\AbstractValidator
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::setTranslatorEnabled() |
Parameters
$flag
bool
Returns
Set translation text domain
setTranslatorTextDomain(string $textDomain) : \Zend\Validator\AbstractValidator
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::setTranslatorTextDomain() |
Parameters
$textDomain
string
Returns
Set flag indicating whether or not value should be obfuscated in messages
setValueObscured(bool $flag) : \Zend\Validator\AbstractValidator
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::setValueObscured() |
Parameters
$flag
bool
Returns
Set whether IDN domains are validated
useIdnCheck(bool $useIdnCheck) : \Zend\Validator\Hostname
This only applies when DNS hostnames are validated
Parameters
$useIdnCheck
bool
Set to true to validate IDN domains
Returns
Set whether the TLD element of a hostname is validated
useTldCheck(bool $useTldCheck) : \Zend\Validator\Hostname
This only applies when DNS hostnames are validated
Parameters
$useTldCheck
bool
Set to true to validate TLD elements
Returns
Constructs and returns a validation failure message with the given message key and value.
createMessage(string $messageKey, string | array | object $value) : string
Inherited
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.
inherited_from |
\Zend\Validator\AbstractValidator::createMessage() |
Parameters
$messageKey
string
$value
stringarrayobject
Returns
string
Decodes a punycode encoded string to it's original utf8 string
Returns false in case of a decoding failure.
decodePunycode(string $encoded) : string | false
Parameters
$encoded
string
Punycode encoded string to decode
Returns
string
false
error()
error(string $messageKey, string $value) : void
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::error() |
Parameters
$messageKey
string
Returns the validation value
getValue() : mixed
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::getValue() |
Returns
mixed
Value to be validated
Sets the value to be validated and clears the messages and errors arrays
setValue(mixed $value) : void
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::setValue() |
Parameters
$value
mixed
Translate a validation message
translateMessage(string $messageKey, string $message) : string
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::translateMessage() |
Parameters
$messageKey
string
$message
string
Returns
string
Properties
$abstractOptions
$abstractOptions
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::$$abstractOptions |
Default text domain to be used with translator
$defaultTranslatorTextDomain : string
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::$$defaultTranslatorTextDomain |
Limits the maximum returned length of an error message
$messageLength : int
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::$$messageLength |
$messageTemplates
$messageTemplates : array
$messageVariables
$messageVariables : array
Options for the hostname validator
$options : array
Array for valid Idns
$validIdns : array
see |
\Zend\Validator\http://www.iana.org/domains/idn-tables/ |
Array of valid top-level-domains
$validTlds : array
see |
\Zend\Validator\ftp://data.iana.org/TLD/tlds-alpha-by-domain.txt |
see |
\Zend\Validator\http://www.iana.org/domains/root/db/ |
The value to be validated
$value : mixed
Inherited
inherited_from |
\Zend\Validator\AbstractValidator::$$value |
Constants
CANNOT_DECODE_PUNYCODE
CANNOT_DECODE_PUNYCODE
INVALID_DASH
INVALID_DASH
INVALID_HOSTNAME
INVALID_HOSTNAME
INVALID_HOSTNAME_SCHEMA
INVALID_HOSTNAME_SCHEMA
INVALID_LOCAL_NAME
INVALID_LOCAL_NAME
IP_ADDRESS_NOT_ALLOWED
IP_ADDRESS_NOT_ALLOWED
LOCAL_NAME_NOT_ALLOWED
LOCAL_NAME_NOT_ALLOWED
UNDECIPHERABLE_TLD
UNDECIPHERABLE_TLD