\Zend_Validate_Hostname
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-2011 Zend Technologies USA Inc. (http://www.zend.com)
- License: http://framework.zend.com/license/new-bsd New BSD License
Synopsis
class Zend_Validate_Hostname
extends Zend_Validate_Abstract
{
- // constants
- 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_ALL = 7;
- const ALLOW_URI = 8;
- // members
- protected array $_messageTemplates = ;
- protected array $_messageVariables = ;
- protected array $_validTlds = ;
- protected $_tld;
- protected array $_validIdns = ;
- protected array $_idnLength = ;
- protected array $_options = ;
- // Inherited members from Zend_Validate_Abstract
- protected $_value;
- protected array $_messageVariables;
- protected array $_messageTemplates;
- protected array $_messages;
- protected bool $_obscureValue;
- protected array $_errors;
- protected Zend_Translate $_translator;
- protected static Zend_Translate $_defaultTranslator;
- protected Boolean $_translatorDisabled;
- protected static Integer $_messageLength;
- // methods
- public void __construct()
- public array getOptions()
- public Zend_Validate_Hostname setOptions()
- public Zend_Validate_Ip getIpValidator()
- public void; setIpValidator()
- public integer getAllow()
- public Zend_Validate_Hostname setAllow()
- public boolean getValidateIdn()
- public void setValidateIdn()
- public boolean getValidateTld()
- public void setValidateTld()
- public boolean isValid()
- protected string decodePunycode()
- // Inherited methods from Zend_Validate_Abstract
- public array getMessages()
- public array getMessageVariables()
- public array getMessageTemplates()
- public Zend_Validate_Abstract setMessage()
- public Zend_Validate_Abstract setMessages()
- public mixed __get()
- protected string _createMessage()
- protected void _error()
- protected void _setValue()
- public array getErrors()
- public Zend_Validate_Abstract setObscureValue()
- public bool getObscureValue()
- public Zend_Validate_Abstract setTranslator()
- public Zend_Translate_Adapter|null getTranslator()
- public bool hasTranslator()
- public static void setDefaultTranslator()
- public static Zend_Translate_Adapter|null getDefaultTranslator()
- public static boolean hasDefaultTranslator()
- public Zend_Validate_Abstract setDisableTranslator()
- public bool translatorIsDisabled()
- public static integer getMessageLength()
- public static void setMessageLength()
Hierarchy
Extends
Constants
Name | Value |
---|---|
CANNOT_DECODE_PUNYCODE | 'hostnameCannotDecodePunycode' |
INVALID | 'hostnameInvalid' |
INVALID_DASH | 'hostnameDashCharacter' |
INVALID_HOSTNAME | 'hostnameInvalidHostname' |
INVALID_HOSTNAME_SCHEMA | 'hostnameInvalidHostnameSchema' |
INVALID_LOCAL_NAME | 'hostnameInvalidLocalName' |
INVALID_URI | 'hostnameInvalidUri' |
IP_ADDRESS_NOT_ALLOWED | 'hostnameIpAddressNotAllowed' |
LOCAL_NAME_NOT_ALLOWED | 'hostnameLocalNameNotAllowed' |
UNDECIPHERABLE_TLD | 'hostnameUndecipherableTld' |
UNKNOWN_TLD | 'hostnameUnknownTld' |
ALLOW_DNS | 1 |
ALLOW_IP | 2 |
ALLOW_LOCAL | 4 |
ALLOW_ALL | 7 |
ALLOW_URI | 8 |
Members
protected
- $_defaultTranslator
—
Zend_Translate
Default translation object for all validate objects - $_errors
—
array
Array of validation failure message codes - $_idnLength
- $_messageLength
—
Integer
Limits the maximum returned length of a error message - $_messageTemplates — array
- $_messageTemplates
—
array
Validation failure message template definitions - $_messageVariables — array
- $_messageVariables
—
array
Additional variables available for validation failure messages - $_messages
—
array
Array of validation failure messages - $_obscureValue
—
bool
Flag indidcating whether or not value should be obfuscated in error messages - $_options
- $_tld — string
- $_translator
—
Zend_Translate
Translation object - $_translatorDisabled
—
Boolean
Is translation disabled? - $_validIdns
—
array
Array for valid Idns - $_validTlds
—
array
Array of valid top-level-domains - $_value
—
mixed
The value to be validated
Methods
protected
- decodePunycode() — Decodes a punycode encoded string to it's original utf8 string In case of a decoding failure the original string is returned
public
- __construct() — Sets validator options
- getAllow() — Returns the allow option
- getIpValidator() — Returns the set ip validator
- getOptions() — Returns all set options
- getValidateIdn() — Returns the set idn option
- getValidateTld() — Returns the set tld option
- isValid() — Defined by Zend_Validate_Interface
- setAllow() — Sets the allow option
- setIpValidator()
- setOptions() — Sets the options for this validator
- setValidateIdn() — Set whether IDN domains are validated
- setValidateTld() — Set whether the TLD element of a hostname is validated
Inherited from Zend_Validate_Abstract
protected
- _createMessage() — Constructs and returns a validation failure message with the given message key and value.
- _error()
- _setValue() — Sets the value to be validated and clears the messages and errors arrays
public
- __get() — Magic function returns the value of the requested property, if and only if it is the value or a message variable.
- getDefaultTranslator() — Get default translation object for all validate objects
- getErrors() — Returns array of validation failure message codes
- getMessageLength() — Returns the maximum allowed message length
- getMessageTemplates() — Returns the message templates from the validator
- getMessageVariables() — Returns an array of the names of variables that are used in constructing validation failure messages
- getMessages() — Returns array of validation failure messages
- getObscureValue() — Retrieve flag indicating whether or not value should be obfuscated in messages
- getTranslator() — Return translation object
- hasDefaultTranslator() — Is there a default translation object set?
- hasTranslator() — Does this validator have its own specific translator?
- setDefaultTranslator() — Set default translation object for all validate objects
- setDisableTranslator() — Indicate whether or not translation should be disabled
- setMessage() — Sets the validation failure message template for a particular key
- setMessageLength() — Sets the maximum allowed message length
- 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.
- setObscureValue() — Set flag indicating whether or not value should be obfuscated in messages
- setTranslator() — Set translation object
- translatorIsDisabled() — Is translation disabled?