Current code pushes all malli default schemas into the atom. This has some drawbacks:
user can accidentally override any default schema, e.g. write :int to (m/-string-schema)
common pattern with malli is to build your mutable registry to application-level, e.g.
(require '[malli.core :as m])
(require '[malli.registry :as mr])
(def registry (atom {}))
(defn register! [type schema]
(swap! registry assoc type schema))
(mr/set-default-registry!
;; linear search
(mr/composite-registry
;; core schemas
(m/default-schemas)
;; to support Var references
(mr/var-registry)
;; mutable (spec-like) registry
(mr/mutable-registry registry)))
this PR changes the registry to be a composite registry (linear seach) over the following:
malli.core/default-registry -> users can define this into anything, see above. If user has already a mutable registry, those are automatically available with guardrails. Also, in ClojureScript, one can just register few basic schemas for smaller bundle size (malli starts with 2kb gzipped)
the guardrail default registry.
having 1 separated from 2 also means one can't override the base schemas, e.g. :int is always :int.
Current code pushes all malli default schemas into the atom. This has some drawbacks:
:int
to(m/-string-schema)
this PR changes the registry to be a
composite registry
(linear seach) over the following:malli.core/default-registry
-> users can define this into anything, see above. If user has already a mutable registry, those are automatically available with guardrails. Also, in ClojureScript, one can just register few basic schemas for smaller bundle size (malli starts with 2kb gzipped)having 1 separated from 2 also means one can't override the base schemas, e.g.
:int
is always:int
.