Fork me on GitHub
#malli
<
2021-11-05
>
robert-stuttaford07:11:08

(def LearningPathItems
  [:schema {:registry
            {::items
             [:map
              [:items
               {:optional true}
               [:vector
                #_(mu/union LearningPathItemBase)
                [:ref ::items]]]
              ;; marker
              ]}}
   ::items])

#_
(m/validate
 LearningPathItems
 {:items [{:items [{:items []}]}]})
this works. but when i want to introduce another spec to mix into the ref'd spec (to specify lots of other keys that any :items child may have), it fails due to :malli.core/invalid-ref. am i forced to put all of those other key specifications directly in at ;; marker , or is there another way to compose it in? I suppose i could just use Clojure to catenate two vectors but that feels dirty 😅

robert-stuttaford07:11:50

this works i guess

(def LearningPathItemBase
  [:map
   [...]])

(def LearningPathItems
  [:schema {:registry
            {::items
             (vec
              (concat
               [:map
                [:items
                 {:optional true}
                 [:vector
                  [:ref ::items]]]]
               (rest LearningPathItemBase)))}}
   ::items])

robert-stuttaford07:11:39

btw the new faster mp/provider is fantastic @ikitommi!

👍 1