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.
Gets the domain (part after the @
symbol) of the email.
A string containing the domain.
Sets the domain (hostname) of the email.
The new domain to set.
Gets the username (part before the @
symbol) of the email.
A string containing the username.
Sets the username of the email.
The new username to set.
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.