0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-18 10:41:29 -05:00

🐛 Fix usability issue on team invitation dialog.

Happens when user select (autocompletion), writes or
pastes an email that starts and/or ends with a trailing
spaces. The new spec allows tailing spaces but conforms
to a valid email address without trailing spaces.
This commit is contained in:
Andrey Antukh 2021-04-13 12:12:56 +02:00
parent 99bcf0484a
commit 239ec12529

View file

@ -25,9 +25,6 @@
;; --- Constants
(def email-rx
#"^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$")
(def uuid-rx
#"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$")
@ -86,12 +83,6 @@
v
::s/invalid))
(defn- email-conformer
[v]
(if (and (string? v) (re-matches email-rx v))
v
::s/invalid))
(defn keyword-conformer
[v]
(cond
@ -109,7 +100,6 @@
(s/def ::keyword (s/conformer keyword-conformer name))
(s/def ::inst inst?)
(s/def ::string string?)
(s/def ::email (s/conformer email-conformer str))
(s/def ::color (s/conformer color-conformer str))
(s/def ::uuid (s/conformer uuid-conformer str))
(s/def ::boolean (s/conformer boolean-conformer boolean-unformer))
@ -134,6 +124,18 @@
(>= % min-safe-int)
(<= % max-safe-int)))
;; --- SPEC: email
(let [re #"[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+"
cfn (fn [v]
(if (string? v)
(if-let [matches (re-seq re v)]
(first matches)
(do ::s/invalid))
::s/invalid))]
(s/def ::email (s/conformer cfn str)))
;; --- Macros
(defn spec-assert*