Class Zend_Validate_Hostname

Description

Implements interfaces:

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

Located in /Zend/Validate/Hostname.php (line 36)


	
			
Class Constant Summary
 ALLOW_ALL = 7
 ALLOW_DNS = 1
 ALLOW_IP = 2
 REGEX_LOCAL_DEFAULT = '/^(?:[^\W_](?:[^\W_]|-){0,61}[^\W_]\.)*(?:[^\W_](?:[^\W_]|-){0,61}[^\W_])\.?$/'
Variable Summary
 integer $_allow
 array $_messages
 array $_regex
 array $_validTlds
Method Summary
 void __construct ([integer $allow = self::ALLOW_DNS])
 integer getAllow ()
 array getMessages ()
 string getRegex (string $type)
 boolean isValid (mixed $value)
 Zend_Validate_Hostname setAllow (integer $allow)
 Zend_Validate_Hostname setRegex (string $type, string $pattern)
Variables
integer $_allow (line 69)

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

  • access: protected
array $_messages = array() (line 85)

Array of validation failure messages

  • access: protected
array $_regex = array(
'local' => self::REGEX_LOCAL_DEFAULT
)
(line 76)

Array of regular expressions used for validation

  • 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 93)

Array of valid top-level-domains

Methods
Constructor __construct (line 128)

Sets validator options

void __construct ([integer $allow = self::ALLOW_DNS])
  • integer $allow
getAllow (line 138)

Returns the allow option

  • access: public
integer getAllow ()
getMessages (line 329)

Defined by Zend_Validate_Interface

Returns array of validation failure messages

  • access: public
array getMessages ()

Implementation of:
Zend_Validate_Interface::getMessages()
Returns an array of messages that explain why a previous isValid() call returned false
getRegex (line 161)

Returns the regular expression used for validating $type hostnames

  • access: public
string getRegex (string $type)
  • string $type
isValid (line 188)

Defined by Zend_Validate_Interface

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

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

Implementation of:
Zend_Validate_Interface::isValid()
Returns true if and only if $value meets the validation requirements
setAllow (line 149)

Sets the allow option

  • return: Provides a fluent interface
  • access: public
Zend_Validate_Hostname setAllow (integer $allow)
  • integer $allow
setRegex (line 173)

Enter description here...

  • return: Provides a fluent interface
  • access: public
Zend_Validate_Hostname setRegex (string $type, string $pattern)
  • string $type
  • string $pattern
_checkRegexType (line 341)

Throws an exception if a regex for $type does not exist

  • return: Provides a fluent interface
  • access: protected
  • throws: Zend_Validate_Exception
Zend_Validate_Hostname _checkRegexType (string $type)
  • string $type
Class Constants
ALLOW_ALL = 7 (line 56)

Allows all types of hostnames

ALLOW_DNS = 1 (line 41)

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

ALLOW_IP = 2 (line 46)

Allows IP addresses

ALLOW_LOCAL = 4 (line 51)

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

REGEX_LOCAL_DEFAULT = '/^(?:[^\W_](?:[^\W_]|-){0,61}[^\W_]\.)*(?:[^\W_](?:[^\W_]|-){0,61}[^\W_])\.?$/' (line 62)

Default regular expression for local network name validation

  • todo: 0.9 Check allowed characters for a local hostname and possibly deprecate this constant

Documentation generated on Wed, 21 Feb 2007 11:50:20 -0800 by phpDocumentor 1.3.1