The goog.format.EmailAddress Class

goog.format.EmailAddress(opt_address, opt_name)

Formats an email address string for display, and allows for extraction of The individual componants of the address.

opt_address {string=}
The email address.
opt_name {string=}
The name associated with the email address.

.getAddress()

Get the email address.

returns {string}
The email address.

.getName()

Get the name associated with the email address.

returns {string}
The name or personal portion of the address.

.isValid()

Determines is the current object is a valid email address.

returns {boolean}
Whether the email address is valid.

.isValidAddrSpec(str)

Checks if the provided string is a valid address spec (local@domain.com).

str {string}
The email address to check.
returns {boolean}
Whether the provided string is a valid address spec.

.isValidAddress(str)

Checks if the provided string is a valid email address. Supports both simple email addresses (address specs) and addresses that contain display names.

str {string}
The email address to check.
returns {boolean}
Whether the provided string is a valid address.

.parse(addr)

Parse an email address of the form "name" <address> into an email address.

addr {string}
The address string.
returns {goog.format.EmailAddress}
The parsed address.

.parseList(str)

Parse a string containing email addresses of the form "name" <address> into an array of email addresses.

str {string}
The address list.
returns {Array.<goog.format.EmailAddress>}
The parsed emails.

.setAddress(address)

Set the email address.

address {string}
The email address.

.setName(name)

Set the name associated with the email address.

name {string}
The name to associate.

.toString()

Return the address in a standard format: - remove extra spaces. - Surround name with quotes if it contains special characters.

returns {string}
The cleaned address.