metosin / malli

High-performance data-driven data specification library for Clojure/Script.
Eclipse Public License 2.0
1.44k stars 204 forks source link

m/deref-recursive doesn't play nice with :merge schema #997

Closed irigarae closed 5 months ago

irigarae commented 5 months ago

Hi, I noticed the newly released deref-recursive doesn't give what I would expect for :merge schemas. Bug? Or deref-recursive is intended for something else?

(m/deref
 [:merge
  [:map [:x :int]]
  [:map [:y :int]]]
 {:registry (merge (m/default-schemas) (mu/schemas))})
#_=> [:map [:x :int] [:y :int]]

(m/deref-all
 [:merge
  [:map [:x :int]]
  [:map [:y :int]]]
 {:registry (merge (m/default-schemas) (mu/schemas))})
#_=> [:map [:x :int] [:y :int]]

(m/deref-recursive
 [:merge
  [:map [:x :int]]
  [:map [:y :int]]]
 {:registry (merge (m/default-schemas) (mu/schemas))})
#_=> [:map [:x :int]]
ikitommi commented 5 months ago

Ok, this is a bug in either :merge or in the new util. Thanks for reporting.

ikitommi commented 5 months ago

Ok, this is the reason - https://github.com/metosin/malli/blob/master/src/malli/core.cljc#L2321 takes just first. The utility schemas have multiple children.