Skip to content
Snippets Groups Projects
Commit 700f8c1c authored by Allen Gilliland's avatar Allen Gilliland
Browse files

add a convenience function to test if a string is a valid email address.

parent a751b3c0
No related branches found
No related tags found
No related merge requests found
......@@ -128,3 +128,11 @@
[pred? args & [default]]
(if (pred? (first args)) [(first args) (next args)]
[default args]))
(defn is-email?
"Returns true if v is an email address"
[v]
(if (nil? v)
false
(boolean (re-matches #"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?" v))))
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment