When I use clojure.spec, I am trying to figure out how to spec nested seq/vector. Here is my failing example:
(s/def ::test (s/cat :s any? :r (s/cat :int int?)))
(s/explain-str ::test ["test" [1]])
;; => "[1] - failed: int? in: [1] at: [:r :int] spec: :ct.biz.ext2-test/test\n"
As you can see it fails on [1] being explained against int?. Why not against (s/cat :int int?)? It looks like it's actually flattening the spec, which was mentioned in some note somewhere. But how would I correctly spec my data?
s/catis a regular expression. So it will match all expression that fit.s/specallows to create a nested spec. So the correct spec for above is:(s/cat :any any? :r (s/spec (s/cat int int?)))