0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-27 15:11:26 -05:00

🎉 Add parse email helper function

This commit is contained in:
Andrey Antukh 2022-03-03 14:15:45 +01:00
parent 1cf9ad55c6
commit a1c3789ec2

View file

@ -161,14 +161,14 @@
(def email-re #"[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+")
(defn parse-email
[s]
(some->> s (re-seq email-re) first))
(s/def ::email
(s/conformer
(fn [v]
(if (string? v)
(if-let [matches (re-seq email-re v)]
(first matches)
(do ::s/invalid))
::s/invalid))
(or (parse-email v) ::s/invalid))
str))
(s/def ::set-of-emails