Currently selecting is helpful to create tailored schemas:
(ms/select Person ^:only [:name :age {:country [:iso]}])
But when used to generate data you often may want to set the properties of some attributes to make it an actually helpful generator for the test/context you'r working on.
So:
;; we'd want to turn this...
[:map [:name string?] [:age pos-int?] :country [:map [:iso string?]]]
;; ...into this:
[:map
[:name {:gen/return "Gert"} string?]
[:age [:int {:min 18 :max 50}]]
[:country
[:map
[:iso {:gen/elements ["NL" "DK"]} string?]]]]
Sketching:
(-> Person
(ms/select ^:only [:name :age {:country [:iso]}])
(ms/merge-in-properties [:name] {:gen/return "Gert"})
(ms/merge-in-properties [:age] {:min 18 :max 50})
(ms/merge-in-properties [:country iso] {:gen/elements ["NL" "DK"]})
(mg/generate)) ;; => {:name "Gert" :age 21 :country "DK"}
or even:
(-> Person
(ms/select ^:only [:name :age {:country [:iso]}])
(ms/merge-in-properties [[:name {:gen/return "Gert"}]
[:age {:min 18 :max 50}]
[:country [:iso {:gen/elements ["NL" "DK"]}]]])
(mg/generate)) ;; => {:name "Gert" :age 21 :country "DK"}
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too