mirror of
https://github.com/penpot/penpot.git
synced 2026-09-09 13:39:02 +00:00
🎉 Add parse email helper function
This commit is contained in:
parent
1cf9ad55c6
commit
a1c3789ec2
@ -161,14 +161,14 @@
|
|||||||
|
|
||||||
(def email-re #"[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+")
|
(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/def ::email
|
||||||
(s/conformer
|
(s/conformer
|
||||||
(fn [v]
|
(fn [v]
|
||||||
(if (string? v)
|
(or (parse-email v) ::s/invalid))
|
||||||
(if-let [matches (re-seq email-re v)]
|
|
||||||
(first matches)
|
|
||||||
(do ::s/invalid))
|
|
||||||
::s/invalid))
|
|
||||||
str))
|
str))
|
||||||
|
|
||||||
(s/def ::set-of-emails
|
(s/def ::set-of-emails
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user