Fork me on GitHub
#malli
<
2022-03-22
>
Nikolas Pafitis12:03:18

I have this schema

(def ResourceIdentifier
  [:schema {:registry
            {::resource-key   :keyword
             ::path-param     [:or :string :int]
             ::query-params   map?
             ::resource-ident [:cat
                               [:+ [:or
                                    [:ref ::path-param]
                                    [:ref ::resource-key]]]
                               [:? [:ref ::query-params]]]}}
   ::resource-ident])
and i get a :malli.core/potentially-recursive-seqex although I don't see how it's recursive.

ikitommi12:03:41

you should take away the :ref wrapping. :ref is potentially recursive. Using a plain reference value (e.g. ::path-param) should work ok.

Nikolas Pafitis12:03:49

The equivalent in clojure.spec works fine

(s/def ::resource-key keyword?)
(s/def ::path-param (s/or :string string? :int int?))
(s/def ::query-params map?)
(s/def ::resource-ident (s/cat :path (s/+ (s/or :resource-key ::resource-key
                                                :path-param ::path-param))
                               :query-params (s/? ::query-params)))