Fork me on GitHub
#malli
<
2024-01-11
>
ikitommi18:01:44

One small addition before pushing 0.14.0 out, m/deref-recursive takes ::m/ref-key option to add the de-reffed ref-keys into schema properties:

(m/deref-recursive
 [:schema {:registry {::user-id :uuid
                      ::address [:map
                                 [:street :string]]
                      ::user [:map
                              [:id ::user-id]
                              [:friends [:set [:ref ::user]]]
                              [:address ::address]]}}
  ::user]
 {::m/ref-key :id})
;[:map {:id :user/user}
; [:id [:uuid {:id :user/user-id}]]
; [:friends [:set [:ref :user/user]]]
; [:address [:map {:id :user/address} [:street :string]]]]

👀 1
ikitommi18:01:24

with defaults:

(m/deref-recursive
 [:schema {:registry {::user-id :uuid
                      ::address [:map
                                 [:street :string]]
                      ::user [:map
                              [:id ::user-id]
                              [:friends [:set [:ref ::user]]]
                              [:address ::address]]}}
  ::user])
;[:map 
; [:id :uuid]
; [:friends [:set [:ref :user/user]]]
; [:address [:map [:street :string]]]]