Class Hostname

Summary

Fully Qualified Name: Zend\Validator\Hostname
Extends: AbstractValidator

Description

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

Name Description Defined By
__construct() Sets validator options. Hostname
__get() Magic function returns the value of the requested property, if and only if it is the value or a message variable. AbstractValidator
__invoke() Invoke as command AbstractValidator
getAllow() Returns the allow option Hostname
getDefaultTranslator() Get default translation object for all validate objects AbstractValidator
getDefaultTranslatorTextDomain() Get default translation text domain for all validate objects AbstractValidator
getIdnCheck() Returns the set idn option Hostname
getIpValidator() Returns the set ip validator Hostname
getMessageLength() Returns the maximum allowed message length AbstractValidator
getMessageTemplates() Returns the message templates from the validator AbstractValidator
getMessageVariables() Returns an array of the names of variables that are used in constructing validation failure messages AbstractValidator
getMessages() Returns array of validation failure messages AbstractValidator
getOption() Returns an option AbstractValidator
getOptions() Returns all available options AbstractValidator
getTldCheck() Returns the set tld option Hostname
getTranslator() Return translation object AbstractValidator
getTranslatorTextDomain() Return the translation text domain AbstractValidator
hasDefaultTranslator() Is there a default translation object set? AbstractValidator
hasTranslator() Does this validator have its own specific translator? AbstractValidator
isTranslatorEnabled() Is translation enabled? AbstractValidator
isValid() Defined by Interface Hostname
isValueObscured() Retrieve flag indicating whether or not value should be obfuscated in messages AbstractValidator
setAllow() Sets the allow option Hostname
setDefaultTranslator() Set default translation object for all validate objects AbstractValidator
setDefaultTranslatorTextDomain() Set default translation text domain for all validate objects AbstractValidator
setIpValidator() Hostname
setMessage() Sets the validation failure message template for a particular key AbstractValidator
setMessageLength() Sets the maximum allowed message length AbstractValidator
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. AbstractValidator
setOptions() Sets one or multiple options AbstractValidator
setTranslator() Set translation object AbstractValidator
setTranslatorEnabled() Indicate whether or not translation should be enabled AbstractValidator
setTranslatorTextDomain() Set translation text domain AbstractValidator
setValueObscured() Set flag indicating whether or not value should be obfuscated in messages AbstractValidator
useIdnCheck() Set whether IDN domains are validated Hostname
useTldCheck() Set whether the TLD element of a hostname is validated Hostname

Method Details

__construct()

Sets validator options.

Parameter Name Type Description
$allow int OPTIONAL
$useIdnCheck bool OPTIONAL
$useTldCheck bool Set
$ipValidator \Ip OPTIONAL
$options

Returns:

__get()

Magic function returns the value of the requested property, if and only if it is the value or a message variable.

Parameter Name Type Description
$property string

Returns: mixed

__invoke()

Invoke as command

Parameter Name Type Description
$value mixed

Returns: bool

getAllow()

Returns the allow option

Returns: int

getDefaultTranslator()

Get default translation object for all validate objects

Returns: \Translator\TranslatorInterface|null

getDefaultTranslatorTextDomain()

Get default translation text domain for all validate objects

Returns: string

getIdnCheck()

Returns the set idn option

Returns: bool

getIpValidator()

Returns the set ip validator

Returns: \Ip

getMessageLength()

Returns the maximum allowed message length

Returns: int

getMessageTemplates()

Returns the message templates from the validator

Returns: array

getMessageVariables()

Returns an array of the names of variables that are used in constructing validation failure messages

Returns: array

getMessages()

Returns array of validation failure messages

Returns: array

getOption()

Returns an option

Parameter Name Type Description
$option string Option

Returns: mixed Returned option

getOptions()

Returns all available options

Returns: array Array with all available options

getTldCheck()

Returns the set tld option

Returns: bool

getTranslator()

Return translation object

Returns: \Translator\TranslatorInterface|null

getTranslatorTextDomain()

Return the translation text domain

Returns: string

hasDefaultTranslator()

Is there a default translation object set?

Returns: bool

hasTranslator()

Does this validator have its own specific translator?

Returns: bool

isTranslatorEnabled()

Is translation enabled?

Returns: bool

isValid()

Defined by Interface

Returns true if and only if the $value is a valid hostname with respect to the current allow option

Parameter Name Type Description
$value string

Returns: bool

isValueObscured()

Retrieve flag indicating whether or not value should be obfuscated in messages

Returns: bool

setAllow()

Sets the allow option

Parameter Name Type Description
$allow int

Returns: \Hostname Provides a fluent interface

setDefaultTranslator()

Set default translation object for all validate objects

Parameter Name Type Description
$translator \Translator\TranslatorInterface|null
$textDomain string (optional)

Returns: void

setDefaultTranslatorTextDomain()

Set default translation text domain for all validate objects

Parameter Name Type Description
$textDomain string

Returns: void

setIpValidator()

Parameter Name Type Description
$ipValidator

Returns: void

setMessage()

Sets the validation failure message template for a particular key

Parameter Name Type Description
$messageString string
$messageKey string OPTIONAL

Returns: \AbstractValidator Provides a fluent interface

setMessageLength()

Sets the maximum allowed message length

Parameter Name Type Description
$length int

Returns:

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.

Parameter Name Type Description
$messages array

Returns: \AbstractValidator

setOptions()

Sets one or multiple options

Parameter Name Type Description
$options array|\Traversable Options

Returns: \AbstractValidator Provides fluid interface

setTranslator()

Set translation object

Parameter Name Type Description
$translator \Translator\TranslatorInterface|null
$textDomain string (optional)

Returns: \AbstractValidator

setTranslatorEnabled()

Indicate whether or not translation should be enabled

Parameter Name Type Description
$flag bool

Returns: \AbstractValidator

setTranslatorTextDomain()

Set translation text domain

Parameter Name Type Description
$textDomain string

Returns: \AbstractValidator

setValueObscured()

Set flag indicating whether or not value should be obfuscated in messages

Parameter Name Type Description
$flag bool

Returns: \AbstractValidator

useIdnCheck()

Set whether IDN domains are validated

This only applies when DNS hostnames are validated

Parameter Name Type Description
$useIdnCheck bool Set

Returns: \Hostname

useTldCheck()

Set whether the TLD element of a hostname is validated

This only applies when DNS hostnames are validated

Parameter Name Type Description
$useTldCheck bool Set

Returns: \Hostname

Top