Zend Framework  3.0
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
EmailAddress Class Reference

Public Member Functions

 __construct ($options=[])
 Instantiates hostname validator for local use.
 
 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 (Hostname $hostnameValidator=null)
 
 getAllow ()
 Returns the allow option of the attached hostname validator.
 
 setAllow ($allow)
 Sets the allow option of the hostname validator to use.
 
 isMxSupported ()
 Whether MX checking via getmxrr is supported or not.
 
 getMxCheck ()
 Returns the set validateMx option.
 
 useMxCheck ($mx)
 Set whether we check for a valid MX record via DNS.
 
 getDeepMxCheck ()
 Returns the set deepMxCheck option.
 
 useDeepMxCheck ($deep)
 Use deep validation for MX records.
 
 getDomainCheck ()
 Returns the set domainCheck option.
 
 useDomainCheck ($domain=true)
 Sets if the domain should also be checked or only the local part of the email address.
 
 getMXRecord ()
 Returns the found MX Record information after validation including weight for further processing.
 
 isValid ($value)
 Defined by Zend.
 
- Public Member Functions inherited from AbstractValidator
 __construct ($options=null)
 Abstract constructor for all validators A validator should accept following parameters:
 
 getOption ($option)
 Returns an option.
 
 getOptions ()
 Returns all available options.
 
 setOptions ($options=[])
 Sets one or multiple options.
 
 getMessages ()
 Returns array of validation failure messages.
 
 __invoke ($value)
 Invoke as command.
 
 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.
 
 setValueObscured ($flag)
 Set flag indicating whether or not value should be obfuscated in messages.
 
 isValueObscured ()
 Retrieve flag indicating whether or not value should be obfuscated in messages.
 
 setTranslator (Translator\TranslatorInterface $translator=null, $textDomain=null)
 Set translation object.
 
 getTranslator ()
 Return translation object.
 
 hasTranslator ()
 Does this validator have its own specific translator?
 
 setTranslatorTextDomain ($textDomain= 'default')
 Set translation text domain.
 
 getTranslatorTextDomain ()
 Return the translation text domain.
 
 setTranslatorEnabled ($flag=true)
 Indicate whether or not translation should be enabled.
 
 isTranslatorEnabled ()
 Is translation enabled?
 
- Public Member Functions inherited from TranslatorAwareInterface
 setTranslator (TranslatorInterface $translator=null, $textDomain=null)
 Sets translator to use in helper.
 

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 Member Functions

 isReserved ($host)
 Returns if the given host is reserved.
 
 validateLocalPart ()
 Internal method to validate the local part of the email address.
 
 validateMXRecords ()
 Internal method to validate the servers MX records.
 
 validateHostnamePart ()
 Internal method to validate the hostname part of the email address.
 
 splitEmailParts ($value)
 Splits the given value in hostname and local part of the email address.
 
 idnToAscii ($email)
 Safely convert UTF-8 encoded domain name to ASCII.
 
 idnToUtf8 ($email)
 Safely convert ASCII encoded domain name to UTF-8.
 
- Protected Member Functions inherited from AbstractValidator
 createMessage ($messageKey, $value)
 Constructs and returns a validation failure message with the given message key and value.
 
 error ($messageKey, $value=null)
 
 getValue ()
 Returns the validation value.
 
 setValue ($value)
 Sets the value to be validated and clears the messages and errors arrays.
 
 translateMessage ($messageKey, $message)
 Translate a validation message.
 

Protected Attributes

 $messageTemplates
 
 $messageVariables
 
 $hostname
 
 $localPart
 
 $mxRecord = []
 
 $options
 Internal options array.
 
- Protected Attributes inherited from AbstractValidator
 $value
 
 $abstractOptions
 

Additional Inherited Members

- Static Public Member Functions inherited from AbstractValidator
static setDefaultTranslator (Translator\TranslatorInterface $translator=null, $textDomain=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 setDefaultTranslatorTextDomain ($textDomain= 'default')
 Set default translation text domain for all validate objects.
 
static getDefaultTranslatorTextDomain ()
 Get default translation text domain for all validate objects.
 
static getMessageLength ()
 Returns the maximum allowed message length.
 
static setMessageLength ($length=-1)
 Sets the maximum allowed message length.
 
- Static Protected Attributes inherited from AbstractValidator
static $defaultTranslator
 
static $defaultTranslatorTextDomain = 'default'
 
static $messageLength = -1
 

Constructor & Destructor Documentation

__construct (   $options = [])

Instantiates hostname validator for local use.

The following additional option keys are supported: 'hostnameValidator' => A hostname validator, see Zend 'allow' => Options for the hostname validator, see Zend::ALLOW_* 'strict' => Whether to adhere to strictest requirements in the spec 'useMxCheck' => If MX check should be enabled, boolean 'useDeepMxCheck' => If a deep MX check should be done, boolean

Parameters
array | \Traversable$optionsOPTIONAL

Member Function Documentation

getAllow ( )

Returns the allow option of the attached hostname validator.

Returns
int
getDeepMxCheck ( )

Returns the set deepMxCheck option.

Returns
bool
getDomainCheck ( )

Returns the set domainCheck option.

Returns
bool
getHostnameValidator ( )

Returns the set hostname validator.

If was not previously set then lazy load a new one

Returns
Hostname
getMxCheck ( )

Returns the set validateMx option.

Returns
bool
getMXRecord ( )

Returns the found MX Record information after validation including weight for further processing.

Returns
array
idnToAscii (   $email)
protected

Safely convert UTF-8 encoded domain name to ASCII.

Parameters
string$emailthe UTF-8 encoded email
Returns
string
idnToUtf8 (   $email)
protected

Safely convert ASCII encoded domain name to UTF-8.

Parameters
string$emailthe ASCII encoded email
Returns
string
isMxSupported ( )

Whether MX checking via getmxrr is supported or not.

Returns
bool
isReserved (   $host)
protected

Returns if the given host is reserved.

The following addresses are seen as reserved '0.0.0.0/8', '10.0.0.0/8', '127.0.0.0/8' '100.64.0.0/10' '172.16.0.0/12' '198.18.0.0/15' '169.254.0.0/16', '192.168.0.0/16' '192.0.2.0/24', '192.88.99.0/24', '198.51.100.0/24', '203.0.113.0/24' '224.0.0.0/4', '240.0.0.0/4'

See Also
http://en.wikipedia.org/wiki/Reserved_IP_addresses

As of RFC5753 (JAN 2010), the following blocks are no longer reserved:

isValid (   $value)

Defined by Zend.

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 bool

Implements ValidatorInterface.

setAllow (   $allow)

Sets the allow option of the hostname validator to use.

Parameters
int$allow
Returns
EmailAddress Provides a fluent interface
setHostnameValidator ( Hostname  $hostnameValidator = null)
Parameters
Hostname$hostnameValidatorOPTIONAL
Returns
EmailAddress Provides a fluent interface
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
AbstractValidator Provides a fluent interface
splitEmailParts (   $value)
protected

Splits the given value in hostname and local part of the email address.

Parameters
string$valueEmail address to be split
Returns
bool Returns false when the email can not be split
useDeepMxCheck (   $deep)

Use deep validation for MX records.

Parameters
bool$deepSet deep to true to perform a deep validation process for MX records
Returns
EmailAddress Fluid Interface
useDomainCheck (   $domain = true)

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

Parameters
bool$domain
Returns
EmailAddress Fluid Interface
useMxCheck (   $mx)

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

This only applies when DNS hostnames are validated

Parameters
bool$mxSet allowed to true to validate for MX records, and false to not validate them
Returns
EmailAddress Fluid Interface
validateHostnamePart ( )
protected

Internal method to validate the hostname part of the email address.

Returns
bool
validateLocalPart ( )
protected

Internal method to validate the local part of the email address.

Returns
bool
validateMXRecords ( )
protected

Internal method to validate the servers MX records.

Returns
bool

Member Data Documentation

$hostname
protected
$localPart
protected
$messageTemplates
protected
Initial value:
= [
self::INVALID => "Invalid type given. String expected"
$messageVariables
protected
Initial value:
= [
'hostname' => 'hostname'
$mxRecord = []
protected
$options
protected
Initial value:
= [
'useMxCheck' => false

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'