Retrieves the alias part of the email, which is the portion after the +
symbol
in the username, if it exists.
If the username contains a +
, this method returns the part of the username after the +
.
If there is no +
in the username, it returns undefined
.
The alias part of the email, or undefined
if no alias is present.
Sets or updates the alias part of the email (the portion after the +
symbol in the username).
If undefined
or an empty string is provided, the alias is removed.
The new alias to set. If undefined
or empty, the alias will be removed.
Returns the hash of the email address using the SHA-256 algorithm.
A string containing the SHA-256 hash of the email address.
Sets the domain (hostname) of the email.
The new domain to set.
Sets the username of the email.
The new username to set.
Checks if the email's username contains a +
followed by additional text,
commonly referred to as an alias or "plus addressing".
true
if the email contains an alias, otherwise false
.
Serializes the email address to JSON format, returning the same value as toString()
.
A string representation of the email for JSON serialization.
Returns the full email address as a string.
A string representation of the email.
Verifies the email address using an external API.
Static
canDetermines if the provided value can be parsed as a valid Email
.
This method checks whether the input is either an instance of the Email
class or a valid email string that can be successfully parsed by the
Email.from()
method.
true
if the value can be parsed as an Email
, otherwise false
.
Static
from
The
Email
class represents an email address, providing methods to validate, parse, and manipulate the email address components like username, domain, and TLD. It also supports email validation through an external API.This class is immutable in its interface but allows controlled modifications to the username, hostname, and TLD through getters and setters.