Fork me on GitHub
#malli
<
2023-02-21
>
eggsyntax17:02:03

Hi! Just started using malli in a project for the first time & am really happy with it so far 😍 One question -- is there an equivalent of spec's with-gen, so that I can validate and generate in different ways? In particular I have an :id spec that just needs to be a uuid to be valid, but which I'd like to generate as one of several known real ids.

👍 2
Ben Sless17:02:10

gen/gen property in schema

eggsyntax17:02:40

Awesome, thanks!

eggsyntax17:02:29

Bingo! That was easy 🙂 Whew, it's been a while since I've thought about test.check.generators, though, fun to dig back into that...

ikitommi18:02:35

:gen/schema is also nice, all generator-related properties are described here: https://github.com/metosin/malli#value-generation

👍 2
escherize21:02:39

:gen/elements is also useful when there’s a constrainted or annoying-to-generate shape.

eggsyntax21:02:09

Oh, :gen/elements is handy, I hadn't caught that; I'd instead done

(def UserType
  [:map
   [:id {:gen/gen [:enum fixed-seeds/user-type-ids]}]
   ...])
Thanks, y'all!

David G20:02:32

I'm trying to do a comparison for my team, the pros and cons for spec vs malli. Did anyone make a comprehensive comparison? I see https://github.com/kennyjwilli/specalli as something that can be used to automatically compare the syntax, there's also plenty of benchmarks available. Does anyone know of any github pages that go into other comparison details.

👍 2