malli

https://github.com/metosin/malli :malli:
Samuel McHugh 2021-01-18T19:48:21.014100Z

Hello, I'm trying out Malli and I'm wondering what is the idiomatic approach to spec'ing a finit explicit set of values. Here's an example of a schema which works.

(m/validate
  [:or [:= :foo]
       [:= :bar]
       [:= :baz]]
  :foo)
;=> true
The syntax isn't as compact as I'd expect though. I'd hope something like
(m/validate
  #{:foo :bar :baz}
  :foo)
could work but I haven't seen this in the docs anywhere. Do I have to set up a custom registry for this?

ikitommi 2021-01-18T20:02:41.015500Z

@smchugh230395 try [:enum :foo :bar :baz]. Doc PRs welcome!

✅ 1
Samuel McHugh 2021-01-19T09:06:41.015700Z

I will have a look after work today and make a doc PR. Thanks!