valid? and explain-str give inconsistent results when using coll-of :kind with a registered spec.
(s/def ::vector? vector?)
=> :user/vector?
(s/def ::vector-of-maps (s/coll-of map? :kind ::vector?))
=> :user/vector-of-maps
(s/valid? ::vector-of-maps [{}])
=> false
(s/explain-str ::vector-of-maps [{}])
=> "Success!\n"
Windows XP, MacOS 10.13, JDK 1.8.0_171, Clojure 1.9.0, clojure.spec.alpha
It is not valid to use a spec for :kind.
Comment made by: dalethatcher
Ok, the doc string doesn't match then:
coll-of refers you to "every" which has:
:kind - a pred/spec that the collection type must satisfy, e.g. vector?
(default nil) Note that if :kind is specified and :into is
not, this pred must generate in order for every to generate."
Also I noticed that the documentation for coll-of specifies:
Returns a spec for a collection of items satisfying pred.
But in this case a spec can be used.
The doc was fixed in the newest release of spec.alpha (0.2.168) - see CLJ-2111.
Comment made by: dalethatcher
Understood, sorry to have wasted your time. I'll check the latest source next time, before raising a Jira.
No worries at all! That’s what triage is all about.