mobilizon/lib/web/email/checker.ex

15 lines
470 B
Elixir
Raw Normal View History

2020-01-26 20:36:50 +00:00
defmodule Mobilizon.Web.Email.Checker do
@moduledoc """
2019-09-22 14:26:23 +00:00
Provides a function to test emails against a "not so bad" regex.
"""
2019-09-22 14:26:23 +00:00
# TODO: simplify me!
@email_regex ~r/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
@doc """
2019-09-22 14:26:23 +00:00
Returns whether the email is valid.
"""
2019-09-22 14:26:23 +00:00
@spec valid?(String.t()) :: boolean
def valid?(email), do: email =~ @email_regex
end