Zend Framework  1.12
Public Member Functions | Public Attributes | Protected Attributes | List of all members
Zend_Validate_EmailAddress Class Reference

Public Member Functions

 __construct ($options=array())
 Instantiates hostname validator for local use.
 
 getOptions ()
 Returns all set Options.
 
 setOptions (array $options=array())
 Set options for the email validator.
 
 setMessage ($messageString, $messageKey=null)
 Sets the validation failure message template for a particular key Adds the ability to set messages to the attached hostname validator.
 
 getHostnameValidator ()
 Returns the set hostname validator.
 
 setHostnameValidator (Zend_Validate_Hostname $hostnameValidator=null, $allow=Zend_Validate_Hostname::ALLOW_DNS)
 
 validateMxSupported ()
 Whether MX checking via getmxrr is supported or not.
 
 getValidateMx ()
 Returns the set validateMx option.
 
 setValidateMx ($mx)
 Set whether we check for a valid MX record via DNS.
 
 getDeepMxCheck ()
 Returns the set deepMxCheck option.
 
 setDeepMxCheck ($deep)
 Set whether we check MX record should be a deep validation.
 
 getDomainCheck ()
 Returns the set domainCheck option.
 
 setDomainCheck ($domain=true)
 Sets if the domain should also be checked or only the local part of the email address.
 
 isValid ($value)
 Defined by Zend_Validate_Interface.
 
- Public Member Functions inherited from Zend_Validate_Abstract
 getMessages ()
 Returns array of validation failure messages.
 
 getMessageVariables ()
 Returns an array of the names of variables that are used in constructing validation failure messages.
 
 getMessageTemplates ()
 Returns the message templates from the validator.
 
 setMessage ($messageString, $messageKey=null)
 Sets the validation failure message template for a particular key.
 
 setMessages (array $messages)
 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.
 
 __get ($property)
 Magic function returns the value of the requested property, if and only if it is the value or a message variable.
 
 getErrors ()
 Returns array of validation failure message codes.
 
 setObscureValue ($flag)
 Set flag indicating whether or not value should be obfuscated in messages.
 
 getObscureValue ()
 Retrieve flag indicating whether or not value should be obfuscated in messages.
 
 setTranslator ($translator=null)
 Set translation object.
 
 getTranslator ()
 Return translation object.
 
 hasTranslator ()
 Does this validator have its own specific translator?
 
 setDisableTranslator ($flag)
 Indicate whether or not translation should be disabled.
 
 translatorIsDisabled ()
 Is translation disabled?
 

Public Attributes

const INVALID = 'emailAddressInvalid'
 
const INVALID_FORMAT = 'emailAddressInvalidFormat'
 
const INVALID_HOSTNAME = 'emailAddressInvalidHostname'
 
const INVALID_MX_RECORD = 'emailAddressInvalidMxRecord'
 
const INVALID_SEGMENT = 'emailAddressInvalidSegment'
 
const DOT_ATOM = 'emailAddressDotAtom'
 
const QUOTED_STRING = 'emailAddressQuotedString'
 
const INVALID_LOCAL_PART = 'emailAddressInvalidLocalPart'
 
const LENGTH_EXCEEDED = 'emailAddressLengthExceeded'
 

Protected Attributes

 $_messageTemplates
 
 $_invalidIp
 
 $_messageVariables
 
 $_hostname
 
 $_localPart
 
 $_options
 Internal options array.
 
- Protected Attributes inherited from Zend_Validate_Abstract
 $_value
 
 $_messageVariables = array()
 
 $_messageTemplates = array()
 
 $_messages = array()
 
 $_obscureValue = false
 
 $_errors = array()
 
 $_translator
 
 $_translatorDisabled = false
 

Additional Inherited Members

- Static Public Member Functions inherited from Zend_Validate_Abstract
static setDefaultTranslator ($translator=null)
 Set default translation object for all validate objects.
 
static getDefaultTranslator ()
 Get default translation object for all validate objects.
 
static hasDefaultTranslator ()
 Is there a default translation object set?
 
static getMessageLength ()
 Returns the maximum allowed message length.
 
static setMessageLength ($length=-1)
 Sets the maximum allowed message length.
 
- Protected Member Functions inherited from Zend_Validate_Abstract
 _createMessage ($messageKey, $value)
 Constructs and returns a validation failure message with the given message key and value.
 
 _error ($messageKey, $value=null)
 
 _setValue ($value)
 Sets the value to be validated and clears the messages and errors arrays.
 
- Static Protected Attributes inherited from Zend_Validate_Abstract
static $_defaultTranslator
 
static $_messageLength = -1
 

Constructor & Destructor Documentation

__construct (   $options = array())

Instantiates hostname validator for local use.

The following option keys are supported: 'hostname' => A hostname validator, see Zend_Validate_Hostname 'allow' => Options for the hostname validator, see Zend_Validate_Hostname::ALLOW_* 'mx' => If MX check should be enabled, boolean 'deep' => If a deep MX check should be done, boolean

Parameters
array | Zend_Config$optionsOPTIONAL
Returns
void

Member Function Documentation

getDeepMxCheck ( )

Returns the set deepMxCheck option.

Returns
boolean
getDomainCheck ( )

Returns the set domainCheck option.

Returns
unknown
getHostnameValidator ( )

Returns the set hostname validator.

Returns
Zend_Validate_Hostname
getOptions ( )

Returns all set Options.

Returns
array
getValidateMx ( )

Returns the set validateMx option.

Returns
boolean
isValid (   $value)

Defined by Zend_Validate_Interface.

Returns true if and only if $value is a valid email address according to RFC2822

RFC2822 http://www.columbia.edu/kermit/ascii.html US-ASCII characters string $value boolean

Implements Zend_Validate_Interface.

setDeepMxCheck (   $deep)

Set whether we check MX record should be a deep validation.

Parameters
boolean$deepSet deep to true to perform a deep validation process for MX records
Returns
Zend_Validate_EmailAddress Fluid Interface
setDomainCheck (   $domain = true)

Sets if the domain should also be checked or only the local part of the email address.

Parameters
boolean$domain
Returns
Zend_Validate_EmailAddress Fluid Interface
setHostnameValidator ( Zend_Validate_Hostname  $hostnameValidator = null,
  $allow = Zend_Validate_Hostname::ALLOW_DNS 
)
Parameters
Zend_Validate_Hostname$hostnameValidatorOPTIONAL
int$allowOPTIONAL
Returns
void
setMessage (   $messageString,
  $messageKey = null 
)

Sets the validation failure message template for a particular key Adds the ability to set messages to the attached hostname validator.

Parameters
string$messageString
string$messageKeyOPTIONAL
Returns
Zend_Validate_Abstract Provides a fluent interface
Exceptions
Zend_Validate_Exception
setOptions ( array  $options = array())

Set options for the email validator.

Parameters
array$options
Returns
Zend_Validate_EmailAddress fluid interface
setValidateMx (   $mx)

Set whether we check for a valid MX record via DNS.

This only applies when DNS hostnames are validated

Parameters
boolean$mxSet allowed to true to validate for MX records, and false to not validate them
Returns
Zend_Validate_EmailAddress Fluid Interface
validateMxSupported ( )

Whether MX checking via getmxrr is supported or not.

This currently only works on UNIX systems

Returns
boolean

Member Data Documentation

$_hostname
protected
$_invalidIp
protected
Initial value:
= array(
'0' => '0.0.0.0/8',
'10' => '10.0.0.0/8',
'100' => '100.64.0.0/10',
'127' => '127.0.0.0/8',
'169' => '169.254.0.0/16',
'172' => '172.16.0.0/12',
'192' => array(
'192.0.0.0/24',
'192.0.2.0/24',
'192.88.99.0/24',
'192.168.0.0/16'
),
'198' => '198.18.0.0/15',
'224' => '224.0.0.0/4',
'240' => '240.0.0.0/4'
)
$_localPart
protected
$_messageTemplates
protected
Initial value:
= array(
self::INVALID => "Invalid type given. String expected",
self::INVALID_FORMAT => "'%value%' is not a valid email address in the basic format local-part@hostname",
self::INVALID_HOSTNAME => "'%hostname%' is not a valid hostname for email address '%value%'",
self::INVALID_MX_RECORD => "'%hostname%' does not appear to have a valid MX record for the email address '%value%'",
self::INVALID_SEGMENT => "'%hostname%' is not in a routable network segment. The email address '%value%' should not be resolved from public network",
self::DOT_ATOM => "'%localPart%' can not be matched against dot-atom format",
self::QUOTED_STRING => "'%localPart%' can not be matched against quoted-string format",
self::INVALID_LOCAL_PART => "'%localPart%' is not a valid local part for email address '%value%'",
self::LENGTH_EXCEEDED => "'%value%' exceeds the allowed length",
)
$_messageVariables
protected
Initial value:
= array(
'hostname' => '_hostname',
'localPart' => '_localPart'
)
$_options
protected
Initial value:
= array(
'mx' => false,
'deep' => false,
'domain' => true,
'hostname' => null
)

Internal options array.

const DOT_ATOM = 'emailAddressDotAtom'
const INVALID = 'emailAddressInvalid'
const INVALID_FORMAT = 'emailAddressInvalidFormat'
const INVALID_HOSTNAME = 'emailAddressInvalidHostname'
const INVALID_LOCAL_PART = 'emailAddressInvalidLocalPart'
const INVALID_MX_RECORD = 'emailAddressInvalidMxRecord'
const INVALID_SEGMENT = 'emailAddressInvalidSegment'
const LENGTH_EXCEEDED = 'emailAddressLengthExceeded'
const QUOTED_STRING = 'emailAddressQuotedString'