Fork me on GitHub
#clojure-spec
<
2016-11-07
>
norton07:11:15

Has someone an example where spec instrumentation using the :replace option works? I tried a simple example to override the ranged-rand function with one that always returns the start value … but so far no luck.

uwo18:11:15

is there anyway to say that a map should contain one or the other key, besides this?

(s/def ::one-or-the-other
  #(let [ks (set (keys %))]
     (xor (ks :key1) (ks :key2))))

minimal18:11:21

@uwo you can use or in s/keys, see the docstring

minimal18:11:59

The :req key vector supports 'and' and 'or' for key groups:

  (s/keys :req [::x ::y (or ::secret (and ::user ::pwd))] :opt [::z])

uwo18:11:52

@minimal wicked, thanks!

uwo18:11:10

rtfmftw!