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:
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-.]+")
|
||||
|
||||
(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
|
||||
|
|
Loading…
Add table
Reference in a new issue