Skip to content

Commit

Permalink
fix #997
Browse files Browse the repository at this point in the history
  • Loading branch information
ikitommi committed Jan 24, 2024
1 parent 8919b63 commit 3640cd5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/malli/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -2318,7 +2318,7 @@
maybe-set-ref (fn [s r] (if (and ref-key r) (-update-properties s assoc ref-key r) s))]
(-> (walk schema (fn [schema _ children _]
(cond (= :ref (type schema)) schema
(-ref-schema? schema) (-> children (first) (maybe-set-ref (-ref schema)))
(-ref-schema? schema) (maybe-set-ref (deref (-set-children schema children)) (-ref schema))
:else (-set-children schema children)))
{::walk-schema-refs true})
(deref-all)))))
Expand Down
21 changes: 20 additions & 1 deletion test/malli/core_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -3069,4 +3069,23 @@
[:address [:map {:id ::address}
[:street :string]
[:lonlat {:optional true} [:tuple :double :double]]]]]
(m/form (m/deref-recursive schema {::m/ref-key :id}))))))
(m/form (m/deref-recursive schema {::m/ref-key :id}))))
(testing "util schemas"
(let [registry (merge (m/default-schemas) (mu/schemas))]
(is (= [:map [:x :int] [:y :int]]
(m/form (m/deref-recursive
[:merge
[:map [:x :int]]
[:map [:y :int]]]
{:registry registry}))))
(is (= [:map {:id ::xymap}
[::x [:int {:id ::x}]]
[::y [:int {:id ::y}]]]
(m/form (m/deref-recursive
[:schema {:registry {::x :int
::y :int
::xmap [:map ::x]
::ymap [:map ::y]
::xymap [:merge ::xmap ::ymap]}}
::xymap]
{:registry registry, ::m/ref-key :id}))))))))

0 comments on commit 3640cd5

Please sign in to comment.