Fork me on GitHub
#malli
<
2022-03-31
>
mafcocinco02:03:32

Is it possible to supply an arbitrary generator function to an :fn schema (or any schema really)? I know this is trivial, but works for an example:

(malli.g/generate [:map [:a [:fn {:gen/function (fn [] 1)} #(int? %)]]])

ikitommi10:04:48

try :gen/gen.

👍 1
mafcocinco02:03:51

malli throws an exception with that example, so obviously not correct but was hoping there was something like that.

mafcocinco02:03:04

The reason I ask is that we have, for example, a customer schema with first-name, last-name, etc. The schema for first-name uses string? to validate but would like to constrain the generated values to a handful of simple names rather than the universe of all possible strings.

mafcocinco02:03:20

Would definitely make the generated data a bit more readable and user friendly.