Fork me on GitHub
#clojure-spec
<
2020-05-07
>
dvingo22:05:13

is there any way to abstract a spec?

(defmacro to-many-ref-type
 [spec]
 `(s/coll-of (s/or :id u/id? :ident ::ident ~(keyword (name spec)) ~spec) :type vector?)))

(s/def :habit/tasks (to-many-ref-type ::task))
i'm trying this, but I think the macroexpansion of s/def doesn't like it

dvingo22:05:25

actually, i think it's working - my issue is it's not working in cljs, I'll dig into it

dvingo19:05:50

That was my issue! I was trying to use a cljc file and updated them to separate cljs and clj files. it's working now 🙂

👍 4