Fork me on GitHub
#clojure-spec
<
2022-05-19
>
Ho0man11:05:38

Hi everyone, I have a fully specd and complex data structure x-pack where I want to override the ::iid generator for all its sub-entities so they can all share the same value (they all use ::i-commons/iid ), However as the supersession rule in spec/gen explains I am not able to override ::i-commons . Any suggestions for a workaround? Or am I getting something very wrong?

(spec/def ::___x-pack___
  (spec/keys
    :req-un [::i-commons/iid
             ,,,]))

(spec/def ::x-pack
  (spec/spec ::___x-pack___
             :gen (fn []
                    (->> (spec/gen ::___x-pack___)
                         (gen/fmap map->X-Pack)))))
,,,,

(gen/generate (spec/gen ::x-pack {::i-commons/iid #(gen/return "ID1")}) 
Thanks