Fork me on GitHub
#schema
<
2017-01-30
>
rfhayashi17:01:16

hi! is there a way to define a schema where I can have two keys in a map that are mutually exclusive? for example: {:a 1} and {:b 1} are valid, but {:a 1 :b 1} is invalid

metametadata21:01:29

one of the solutions is to define a custom contstraint, smt like:

(def MyMap
  (s/constrained {}
                 (fn [m]
                   (not (and (contains? m :a)
                             (contains? m :b))))
                 'my-map?))