Fork me on GitHub
#clojure-spec
<
2019-05-08
>
favila19:05:42

what's the best way to spec that some relationship holds between the keys and values of a map?

favila19:05:52

in my case I have a map whose keys describe some range, and the vals are vecs of items which should be in the range described by the key

favila19:05:20

(s/and (s/map-of ::x ::y) kv-rel-holds?)

favila19:05:25

nothing better?

Alex Miller (Clojure team)20:05:41

You can spec it as a coll of entry tuples

rich 4
Alex Miller (Clojure team)20:05:54

Then you get both k and v

favila20:05:09

(s/coll-of (s/and (s/tuple ::x ::y) kv-rel-holds?) :into {} :kind map?)

favila20:05:11

like that?

favila20:05:53

generator for that seems easier to make