metosin / malli

High-performance data-driven data specification library for Clojure/Script.
Eclipse Public License 2.0
1.48k stars 210 forks source link

Add malli.generator support for :gen/return #932

Closed radhikalism closed 1 year ago

radhikalism commented 1 year ago

When generating values from schemas, it is not possible to directly express returning a single constant value, as in clojure.test.check.generators/return.

Expected: (mg/generate [:int {:gen/return 1}]) => constantly 1

Actual: Other values are returned because :gen/return is not recognized.

Workarounds:

Although workarounds are available, they are not as idiomatic as :gen/return x corresponding to (gen/return x).