metosin / malli

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

Cannot generate values for regular expression schema #1038

Open lasiltan opened 2 months ago

lasiltan commented 2 months ago

Trying to generate values for a regular expression schema results in an error using malli version 0.15.0:

(mg/generate [:re #"^[0-9]$"])
Execution error (ExceptionInfo) at malli.core/-exception (core.cljc:136).
:test-chuck-not-available

Generating other values works

(mg/generate keyword?)
=> :hL/-Fy

(mg/generate [:enum "a" "b" "c"])
=> "a"
lasiltan commented 2 months ago

I see from the code itself as well as the README that you need to have com.gfredericks/test.chuck as dependency to enable regex generation.

Perhaps the error message could state this instead of just saying :test-chuck-not-available

frenchy64 commented 2 months ago

FWIW this regal schema might also be useful, I'm not sure how a regal generator and test.chuck generator compare though: https://github.com/lambdaisland/regal/pull/48