A simple email address validator for Elixir that first checks the address with a regular expression and then checks if the Top-Level Domain of the host is included in ICANN's List of Top-Level Domains. The package is meant for use with `Ecto.Changeset`.
Homepage Hex Documentation Download
A simple email address validator for Elixir that first checks the address with a regular
expression and then checks if the Top-Level Domain of the host is included in ICANN's
List of Top-Level Domains.
The package is meant for use with Ecto.Changeset
.
If available in Hex, the package can be installed
by adding email_tld_validator
to your list of dependencies in mix.exs
:
def deps do
[
{:email_tld_validator, "~> 0.1.0"}
]
end
The features of this library are split into two modules: EmailTldValidator
and
EmailTldValidator.Ecto
.
To just check if an e-mail is valid outside of an Ecto.Changeset
, use EmailTldValidator/1
:
EmailTldValidator.email_valid?("user@example.com")
# => true
EmailTldValidator.email_valid?("user@example")
# => false (does not match the regular expression)
EmailTldValidator.email_valid?("user@example.foobar")
# => false (non-existent TLD)