Fork me on GitHub
#clojure-spec
<
2017-06-16
>
tap14:06:00

(defn foo [a] a)

(stest/instrument `foo)

(s/def ::m int?)
(s/def ::a (s/* (s/keys :req-un [::m])))

(s/fdef foo
  :args (s/cat :a ::a))

tap14:06:27

Why (s/valid? ::a [{:m 1}]) returns true, but an error is raised for (foo [{:m 1}])?

nwjsmith14:06:45

I think that you want the spec for ::a to be (s/every (s/keys :req-un [::m]))

nwjsmith14:06:44

s/* is a regexp operator, which are used for specifying sequences of data.

nwjsmith14:06:34

In your example above, an error would be raised for (foo [{:m 1}]), but not (foo {:m 1}) or (foo {:m 1} {:m 2})

nwjsmith14:06:23

Ah, looks like you'll want to used coll-of instead of every

tap14:06:31

Ahh, ok. Thanks @nwjsmith