Fork me on GitHub
#malli
<
2021-01-18
>
Samuel McHugh19:01:21

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?

ikitommi20:01:41

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

4
Samuel McHugh09:01:41

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