malli

richiardiandrea 2025-03-25T17:17:54.172179Z

Dear all, does anybody have an example of using :gen/gen (test-gen/fmap... on a key? I cannot seem to make it work...

richiardiandrea 2025-03-25T17:36:31.731809Z

found a way (I hope)

richiardiandrea 2025-03-25T17:37:32.107349Z

the problem is my use of gen/nat for generating positive integers this works:

(assoc %:gen/gen (test-gen/fmap (fn [v] (format "ADR%010d" v))
                                (test-gen/large-integer* {:min 0 :max 9999999999})))

escherize 2025-03-25T21:16:37.900069Z

does :gen/fmap work for you? e.g. (from the readme):

;; :gen/fmap 
(mg/generate
  [:and {:gen/fmap (partial str "kikka_")} string?]
  {:seed 10, :size 10})
;; => "kikka_WT3K0yax2"

❤️ 2
richiardiandrea 2025-03-25T21:17:12.519479Z

yeah ended up using that with gen/any as placeholder :D

richiardiandrea 2025-03-25T21:17:43.308859Z

well that version from test-check anyway for other use cases as well