malli
malli copied to clipboard
Custom registries inside malli.util derivations fails (e.g. mu/optional-keys)
When using operations like mu/optional-keys
, and a custom registry merging m/default-schemas and mu/schemas, it doesn't work properly.
(def Map2
(mu/optional-keys
[:map {:registry (merge
(m/default-schemas)
(mu/schemas)
{::a string?
::b [:merge
[:map [::a [:ref ::a]]]
[:map [:y string?]]]})}
::a
::b]
[::b]))
=>
; Execution error (ExceptionInfo) at malli.core/-fail! (core.cljc:138).
; :malli.core/child-error {:type :enum, :properties nil, :children nil, :min 1, :max nil}
Extracting the registry outside and using it as options to m/schema seems to fix the issue.
(def Map1
(mu/optional-keys
(m/schema
[:map ::a ::b]
{:registry (merge
(m/default-schemas)
(mu/schemas)
{::a string?
::b [:merge
[:map [::a [:ref ::a]]]
[:map [:y string?]]]})})
[::b]))
=> ok!