metosin / malli

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

Fix support ref schemas as vector forms in a registry #848

Closed dvingo closed 1 year ago

dvingo commented 1 year ago

Addresses https://github.com/metosin/malli/issues/847

Unwrap schemas in vector form for subsequent schema lookups.

ikitommi commented 1 year ago

This doesn't look correct:

(let [opts {:registry {:map (m/-map-schema)
                       :int (m/-int-schema)
                       ::test :map
                       ::test-2 [:map [:x :int]]}}]
  (m/schema [::test-2] opts)) ;=> :map
ikitommi commented 1 year ago

I don't think it should be ok to use the vector syntax in the first position (a schema type), e.g. this doesn't make much sense:

(let [opts {:registry {:map (m/-map-schema)
                       :int (m/-int-schema)
                       ::test :map
                       ::test-2 [:map [:x :int]]}}]
  (m/schema [::test-2 {:kikka "kukka"}] opts))

;; ... that would be:

[[:map [:x :int]] {:kikka "kukka"}]
dvingo commented 1 year ago

ahh, thanks for the feedback! I understand now and agree doing this will lead to other problems, I can use other strategies to get the behavior I want.