Class Zend_Validate_Hostname

Description

Please note there are two standalone test scripts for testing IDN characters due to problems with file encoding.

The first is tests/Zend/Validate/HostnameTestStandalone.php which is designed to be run on the command line.

The second is tests/Zend/Validate/HostnameTestForm.php which is designed to be run via HTML to allow users to test entering UTF-8 characters in a form.

  • copyright: Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
  • license: New BSD License

Located in /Validate/Hostname.php (line 54)

Zend_Validate_Abstract
   |
   --Zend_Validate_Hostname
Class Constant Summary
 ALLOW_ALL = 7
 ALLOW_DNS = 1
 ALLOW_IP = 2
 INVALID_DASH = 'hostnameDashCharacter'
 INVALID_HOSTNAME = 'hostnameInvalidHostname'
 INVALID_HOSTNAME_SCHEMA = 'hostnameInvalidHostnameSchema'
 INVALID_LOCAL_NAME = 'hostnameInvalidLocalName'
 IP_ADDRESS_NOT_ALLOWED = 'hostnameIpAddressNotAllowed'
 LOCAL_NAME_NOT_ALLOWED = 'hostnameLocalNameNotAllowed'
 UNDECIPHERABLE_TLD = 'hostnameUndecipherableTld'
 UNKNOWN_TLD = 'hostnameUnknownTld'
Variable Summary
Method Summary
 void __construct ([integer $allow = self::ALLOW_DNS], [boolean $validateIdn = true], [boolean $validateTld = true], [Zend_Validate_Ip $ipValidator = null])
 integer getAllow ()
 boolean isValid (string $value)
 Zend_Validate_Hostname setAllow (integer $allow)
 void; setIpValidator ([Zend_Validate_Ip $ipValidator = null])
 void setValidateIdn (boolean $allowed)
 void setValidateTld (boolean $allowed)
Variables
integer $_allow (line 126)

Bit field of ALLOW constants; determines which types of hostnames are allowed

  • access: protected
array $_messageTemplates = array(
self::IP_ADDRESS_NOT_ALLOWED => "'%value%' appears to be an IP address, but IP addresses are not allowed",
self::UNKNOWN_TLD => "'%value%' appears to be a DNS hostname but cannot match TLD against known list",
self::INVALID_DASH => "'%value%' appears to be a DNS hostname but contains a dash (-) in an invalid position",
self::INVALID_HOSTNAME_SCHEMA => "'%value%' appears to be a DNS hostname but cannot match against hostname schema for TLD '%tld%'",
self::UNDECIPHERABLE_TLD => "'%value%' appears to be a DNS hostname but cannot extract TLD part",
self::INVALID_HOSTNAME => "'%value%' does not match the expected structure for a DNS hostname",
self::INVALID_LOCAL_NAME => "'%value%' does not appear to be a valid local network name",
self::LOCAL_NAME_NOT_ALLOWED => "'%value%' appears to be a local network name but but local network names are not allowed"
)
(line 69)
  • access: protected

Redefinition of:
Zend_Validate_Abstract::$_messageTemplates
array $_messageVariables = array(
'tld' => '_tld'
)
(line 83)
  • access: protected

Redefinition of:
Zend_Validate_Abstract::$_messageVariables
string $_tld (line 172)
  • access: protected
array $_validTlds = array(
'ac', 'ad', 'ae', 'aero', 'af', 'ag', 'ai', 'al', 'am', 'an', 'ao',
'aq', 'ar', 'arpa', 'as', 'at', 'au', 'aw', 'ax', 'az', 'ba', 'bb',
'bd', 'be', 'bf', 'bg', 'bh', 'bi', 'biz', 'bj', 'bm', 'bn', 'bo',
'br', 'bs', 'bt', 'bv', 'bw', 'by', 'bz', 'ca', 'cat', 'cc', 'cd',
'cf', 'cg', 'ch', 'ci', 'ck', 'cl', 'cm', 'cn', 'co', 'com', 'coop',
'cr', 'cu', 'cv', 'cx', 'cy', 'cz', 'de', 'dj', 'dk', 'dm', 'do',
'dz', 'ec', 'edu', 'ee', 'eg', 'er', 'es', 'et', 'eu', 'fi', 'fj',
'fk', 'fm', 'fo', 'fr', 'ga', 'gb', 'gd', 'ge', 'gf', 'gg', 'gh',
'gi', 'gl', 'gm', 'gn', 'gov', 'gp', 'gq', 'gr', 'gs', 'gt', 'gu',
'gw', 'gy', 'hk', 'hm', 'hn', 'hr', 'ht', 'hu', 'id', 'ie', 'il',
'im', 'in', 'info', 'int', 'io', 'iq', 'ir', 'is', 'it', 'je', 'jm',
'jo', 'jobs', 'jp', 'ke', 'kg', 'kh', 'ki', 'km', 'kn', 'kr', 'kw',
'ky', 'kz', 'la', 'lb', 'lc', 'li', 'lk', 'lr', 'ls', 'lt', 'lu',
'lv', 'ly', 'ma', 'mc', 'md', 'mg', 'mh', 'mil', 'mk', 'ml', 'mm',
'mn', 'mo', 'mobi', 'mp', 'mq', 'mr', 'ms', 'mt', 'mu', 'museum', 'mv',
'mw', 'mx', 'my', 'mz', 'na', 'name', 'nc', 'ne', 'net', 'nf', 'ng',
'ni', 'nl', 'no', 'np', 'nr', 'nu', 'nz', 'om', 'org', 'pa', 'pe',
'pf', 'pg', 'ph', 'pk', 'pl', 'pm', 'pn', 'pr', 'pro', 'ps', 'pt',
'pw', 'py', 'qa', 're', 'ro', 'ru', 'rw', 'sa', 'sb', 'sc', 'sd',
'se', 'sg', 'sh', 'si', 'sj', 'sk', 'sl', 'sm', 'sn', 'so', 'sr',
'st', 'su', 'sv', 'sy', 'sz', 'tc', 'td', 'tf', 'tg', 'th', 'tj',
'tk', 'tl', 'tm', 'tn', 'to', 'tp', 'tr', 'travel', 'tt', 'tv', 'tw',
'tz', 'ua', 'ug', 'uk', 'um', 'us', 'uy', 'uz', 'va', 'vc', 've',
'vg', 'vi', 'vn', 'vu', 'wf', 'ws', 'ye', 'yt', 'yu', 'za', 'zm',
'zw'
)
(line 141)

Array of valid top-level-domains

Inherited Variables

Inherited from Zend_Validate_Abstract

Zend_Validate_Abstract::$_errors
Zend_Validate_Abstract::$_messages
Zend_Validate_Abstract::$_value
Methods
Constructor __construct (line 184)

Sets validator options

void __construct ([integer $allow = self::ALLOW_DNS], [boolean $validateIdn = true], [boolean $validateTld = true], [Zend_Validate_Ip $ipValidator = null])
  • integer $allow: OPTIONAL Set what types of hostname to allow (default ALLOW_DNS)
  • boolean $validateIdn: OPTIONAL Set whether IDN domains are validated (default true)
  • boolean $validateTld: OPTIONAL Set whether the TLD element of a hostname is validated (default true)
  • Zend_Validate_Ip $ipValidator: OPTIONAL
getAllow (line 213)

Returns the allow option

  • access: public
integer getAllow ()
isValid (line 277)

Defined by Zend_Validate_Interface

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

  • throws: Zend_Validate_Exception if a fatal error occurs for validation process
  • access: public
boolean isValid (string $value)
  • string $value
setAllow (line 224)

Sets the allow option

  • return: Provides a fluent interface
  • access: public
Zend_Validate_Hostname setAllow (integer $allow)
  • integer $allow
setIpValidator (line 200)
  • access: public
void; setIpValidator ([Zend_Validate_Ip $ipValidator = null])
setValidateIdn (line 237)

Set whether IDN domains are validated

This only applies when DNS hostnames are validated

  • access: public
void setValidateIdn (boolean $allowed)
  • boolean $allowed: Set allowed to true to validate IDNs, and false to not validate them
setValidateTld (line 249)

Set whether the TLD element of a hostname is validated

This only applies when DNS hostnames are validated

  • access: public
void setValidateTld (boolean $allowed)
  • boolean $allowed: Set allowed to true to validate TLDs, and false to not validate them

Inherited Methods

Inherited From Zend_Validate_Abstract

 Zend_Validate_Abstract::getErrors()
 Zend_Validate_Abstract::getMessages()
 Zend_Validate_Abstract::setMessage()
 Zend_Validate_Abstract::setMessages()
 Zend_Validate_Abstract::_createMessage()
 Zend_Validate_Abstract::_error()
 Zend_Validate_Abstract::_setValue()
 Zend_Validate_Abstract::__get()
Class Constants
ALLOW_ALL = 7 (line 105)

Allows all types of hostnames

ALLOW_DNS = 1 (line 90)

Allows Internet domain names (e.g., example.com)

ALLOW_IP = 2 (line 95)

Allows IP addresses

ALLOW_LOCAL = 4 (line 100)

Allows local network names (e.g., localhost, www.localdomain)

INVALID_DASH = 'hostnameDashCharacter' (line 59)
INVALID_HOSTNAME = 'hostnameInvalidHostname' (line 62)
INVALID_HOSTNAME_SCHEMA = 'hostnameInvalidHostnameSchema' (line 60)
INVALID_LOCAL_NAME = 'hostnameInvalidLocalName' (line 63)
IP_ADDRESS_NOT_ALLOWED = 'hostnameIpAddressNotAllowed' (line 57)
LOCAL_NAME_NOT_ALLOWED = 'hostnameLocalNameNotAllowed' (line 64)
UNDECIPHERABLE_TLD = 'hostnameUndecipherableTld' (line 61)
UNKNOWN_TLD = 'hostnameUnknownTld' (line 58)

Documentation generated on Sun, 27 May 2007 23:24:35 -0700 by phpDocumentor 1.3.2