schema

2017-01-30T17:49:16.000028Z

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

metametadata 2017-01-30T21:16:29.000031Z

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?))