metosin / malli

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

mu/deref-recursive #981

Closed ikitommi closed 6 months ago

ikitommi commented 6 months ago

Helper to de-ref schemas (not :refs recursively):

(deftest deref-recursive-test
  (let [schema [:schema {:registry {::user-id :uuid
                                    ::address [:map
                                               [:street :string]
                                               [:lonlat {:optional true} [:tuple :double :double]]]
                                    ::user [:map
                                            [:id ::user-id]
                                            [:name :string]
                                            [:friends {:optional true} [:set [:ref ::user]]]
                                            [:address ::address]]}}
                ::user]
        expected [:map
                  [:id :uuid]
                  [:name :string]
                  [:friends {:optional true} [:set [:ref ::user]]]
                  [:address [:map
                             [:street :string]
                             [:lonlat {:optional true} [:tuple :double :double]]]]]]
    (is (= expected (m/form (mu/deref-recursive schema))))))