2018-11-15 17:35:47 +01:00
|
|
|
defmodule Mobilizon.Service.EmailChecker do
|
|
|
|
@moduledoc """
|
2019-09-22 16:26:23 +02:00
|
|
|
Provides a function to test emails against a "not so bad" regex.
|
2018-11-15 17:35:47 +01:00
|
|
|
"""
|
|
|
|
|
2019-09-22 16:26:23 +02:00
|
|
|
# TODO: simplify me!
|
2018-11-15 17:35:47 +01:00
|
|
|
@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 16:26:23 +02:00
|
|
|
Returns whether the email is valid.
|
2018-11-15 17:35:47 +01:00
|
|
|
"""
|
2019-09-22 16:26:23 +02:00
|
|
|
@spec valid?(String.t()) :: boolean
|
|
|
|
def valid?(email), do: email =~ @email_regex
|
2018-11-15 17:35:47 +01:00
|
|
|
end
|