mirror of
https://github.com/penpot/penpot.git
synced 2025-06-05 08:01:40 +02:00
✨ Backport from develop partial improvements to sm/register! helper
This commit is contained in:
parent
aaa57cb17f
commit
d33a5e6df1
1 changed files with 8 additions and 4 deletions
|
@ -317,11 +317,14 @@
|
||||||
([params]
|
([params]
|
||||||
(cond
|
(cond
|
||||||
(map? params)
|
(map? params)
|
||||||
(let [type (get params :type)]
|
(let [mdata (meta params)
|
||||||
|
type (or (get mdata ::id)
|
||||||
|
(get mdata ::type)
|
||||||
|
(get params :type))]
|
||||||
(assert (qualified-keyword? type) "expected qualified keyword for `type`")
|
(assert (qualified-keyword? type) "expected qualified keyword for `type`")
|
||||||
(let [s (m/-simple-schema params)]
|
(let [s (m/-simple-schema params)]
|
||||||
(swap! sr/registry assoc type s)
|
(swap! sr/registry assoc type s)
|
||||||
nil))
|
s))
|
||||||
|
|
||||||
(vector? params)
|
(vector? params)
|
||||||
(let [mdata (meta params)
|
(let [mdata (meta params)
|
||||||
|
@ -329,11 +332,12 @@
|
||||||
(get mdata ::type))]
|
(get mdata ::type))]
|
||||||
(assert (qualified-keyword? type) "expected qualified keyword to be on metadata")
|
(assert (qualified-keyword? type) "expected qualified keyword to be on metadata")
|
||||||
(swap! sr/registry assoc type params)
|
(swap! sr/registry assoc type params)
|
||||||
nil)
|
params)
|
||||||
|
|
||||||
(m/into-schema? params)
|
(m/into-schema? params)
|
||||||
(let [type (m/-type params)]
|
(let [type (m/-type params)]
|
||||||
(swap! sr/registry assoc type params))
|
(swap! sr/registry assoc type params)
|
||||||
|
params)
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(throw (ex-info "Invalid Arguments" {}))))
|
(throw (ex-info "Invalid Arguments" {}))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue