mirror of
https://github.com/penpot/penpot.git
synced 2025-01-10 00:40:30 -05:00
✨ Add minor improvements to schema and spec namespaces
This commit is contained in:
parent
015fd5bc3a
commit
e0669ebbf8
2 changed files with 15 additions and 3 deletions
|
@ -271,7 +271,18 @@
|
||||||
(fast-check! s type code hint value)))
|
(fast-check! s type code hint value)))
|
||||||
|
|
||||||
(defn register! [type s]
|
(defn register! [type s]
|
||||||
(let [s (if (map? s) (m/-simple-schema s) s)]
|
(let [s (if (map? s)
|
||||||
|
(cond
|
||||||
|
(= :set (:type s))
|
||||||
|
(m/-collection-schema s)
|
||||||
|
|
||||||
|
(= :vec (:type s))
|
||||||
|
(m/-collection-schema s)
|
||||||
|
|
||||||
|
:else
|
||||||
|
(m/-simple-schema s))
|
||||||
|
s)]
|
||||||
|
|
||||||
(swap! sr/registry assoc type s)
|
(swap! sr/registry assoc type s)
|
||||||
nil))
|
nil))
|
||||||
|
|
||||||
|
@ -400,7 +411,7 @@
|
||||||
|
|
||||||
;; NOTE: this is general purpose set spec and should be used over the other
|
;; NOTE: this is general purpose set spec and should be used over the other
|
||||||
|
|
||||||
(register! ::set
|
(def type:set
|
||||||
{:type :set
|
{:type :set
|
||||||
:min 0
|
:min 0
|
||||||
:max 1
|
:max 1
|
||||||
|
@ -477,6 +488,7 @@
|
||||||
|
|
||||||
|
|
||||||
{:pred pred
|
{:pred pred
|
||||||
|
:empty #{}
|
||||||
:type-properties
|
:type-properties
|
||||||
{:title "set"
|
{:title "set"
|
||||||
:description "Set of Strings"
|
:description "Set of Strings"
|
||||||
|
@ -491,6 +503,7 @@
|
||||||
::oapi/items {:type "string"}
|
::oapi/items {:type "string"}
|
||||||
::oapi/unique-items true}}))})
|
::oapi/unique-items true}}))})
|
||||||
|
|
||||||
|
(register! ::set type:set)
|
||||||
|
|
||||||
(register! ::vec
|
(register! ::vec
|
||||||
{:type :vector
|
{:type :vector
|
||||||
|
|
|
@ -442,4 +442,3 @@
|
||||||
cause
|
cause
|
||||||
(when (ex/error? cause)
|
(when (ex/error? cause)
|
||||||
(validation-error? (ex-data cause)))))
|
(validation-error? (ex-data cause)))))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue