mirror of
https://github.com/penpot/penpot.git
synced 2025-01-10 00:40:30 -05:00
✨ Minor imrovements on general purpose specs naming.
This commit is contained in:
parent
a11c7b10ac
commit
8d50852cbe
2 changed files with 39 additions and 13 deletions
|
@ -85,7 +85,7 @@
|
|||
;; a server prop key where initial project is stored.
|
||||
:initial-project-skey "initial-project"})
|
||||
|
||||
(s/def ::flags ::us/words)
|
||||
(s/def ::flags ::us/set-of-keywords)
|
||||
|
||||
;; DEPRECATED PROPERTIES: should be removed in 1.10
|
||||
(s/def ::registration-enabled ::us/boolean)
|
||||
|
|
|
@ -111,16 +111,6 @@
|
|||
(s/def ::point gpt/point?)
|
||||
(s/def ::id ::uuid)
|
||||
|
||||
(s/def ::words
|
||||
(s/conformer
|
||||
(fn [s]
|
||||
(cond
|
||||
(set? s) s
|
||||
(string? s) (into #{} (map keyword) (str/words s))
|
||||
:else ::s/invalid))
|
||||
(fn [s]
|
||||
(str/join " " (map name s)))))
|
||||
|
||||
(defn bytes?
|
||||
"Test if a first parameter is a byte
|
||||
array or not."
|
||||
|
@ -134,7 +124,6 @@
|
|||
|
||||
(s/def ::bytes bytes?)
|
||||
|
||||
|
||||
(s/def ::safe-integer
|
||||
#(and
|
||||
(int? %)
|
||||
|
@ -149,7 +138,27 @@
|
|||
(<= % max-safe-int)))
|
||||
|
||||
|
||||
;; --- SPEC: set of Keywords
|
||||
|
||||
(s/def ::set-of-keywords
|
||||
(s/conformer
|
||||
(fn [s]
|
||||
(let [xform (comp
|
||||
(map (fn [s]
|
||||
(cond
|
||||
(string? s) (keyword s)
|
||||
(keyword? s) s
|
||||
:else nil)))
|
||||
(filter identity))]
|
||||
(cond
|
||||
(set? s) (into #{} xform s)
|
||||
(string? s) (into #{} xform (str/words s))
|
||||
:else ::s/invalid)))
|
||||
(fn [s]
|
||||
(str/join " " (map name s)))))
|
||||
|
||||
;; --- SPEC: email
|
||||
|
||||
(def email-re #"[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+")
|
||||
|
||||
(s/def ::email
|
||||
|
@ -162,6 +171,23 @@
|
|||
::s/invalid))
|
||||
str))
|
||||
|
||||
(s/def ::set-of-emails
|
||||
(s/conformer
|
||||
(fn [v]
|
||||
(cond
|
||||
(string? v)
|
||||
(into #{} (re-seq email-re v))
|
||||
|
||||
(or (set? v) (sequential? v))
|
||||
(->> (str/join " " v)
|
||||
(re-seq email-re)
|
||||
(into #{}))
|
||||
|
||||
:else ::s/invalid))
|
||||
|
||||
(fn [v]
|
||||
(str/join " " v))))
|
||||
|
||||
;; --- SPEC: set-of-str
|
||||
|
||||
(s/def ::set-of-str
|
||||
|
|
Loading…
Reference in a new issue