mirror of
https://github.com/penpot/penpot.git
synced 2025-05-09 23:56:38 +02:00
🎉 Add parse email helper function
This commit is contained in:
parent
1cf9ad55c6
commit
a1c3789ec2
1 changed files with 5 additions and 5 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue