is it possible to only mark :gen/gen as lazy while leaving the rest of the schema as eager? i have a deeply nested multi schema that has a :string entry which should be limited to a set of values that won't be populated until the app starts. i have it defined as a (def Foo (m/schema ...)) and if i put in :gen/gen, the def will fail because malli tries to pull at least one value to make sure it's valid
Interesting setup. I don’t have an easy answer for you, but here are some ideas: • How about having a placeholder for the limited set of values at load-time? Then swap it out for the real set at runtime. • Move this sort of dynamic validation outside the malli schema. You could for example use a walk or a transformer to look at the values that have a certain schema and do more validations. I’m curious, what part of malli “tries to pull at least one value to make sure it’s valid”? I can define a schema with a failing :gen/gen and everything works until I actually ask for a value:
; works:
user=> (def Foo (m/schema [:string {:gen/gen (mg/-never-gen nil)}]))
#'user/Foo
; works:
user=> (mg/generator Foo)
#clojure.test.check.generators.Generator{:gen #object[clojure.test.check.generators$sized$fn__4843 0x1df32c09 "clojure.test.check.generators$sized$fn__4843@1df32c09"]}
; breaks:
user=> (mg/generate Foo)
Execution error (ExceptionInfo) at malli.core/-exception (core.cljc:203).
:malli.generator/unsatisfiable-schema