(s/def ::thing (s/cat :a (s/? string?) :b (s/+ number?)))
(s/def ::seq-of (s/+ ::thing))
(s/conform ::seq-of (list "foo" 1 "bar" 2 3 "qux" 4))
;=> [{:a "foo", :b [1]} [{:a "bar", :b [2 3]} {:a "qux", :b [4]}]]
;EXPECTED
;=> [{:a "foo", :b [1]} {:a "bar", :b [2 3]} {:a "qux", :b [4]}]
;; 只关注第二个元素?
(s/conform ::seq-of (list "foo" 1 2 "bar" 3))
;=> [{:a "foo", :b [1 2]} {:a "bar", :b [2]}]
;; 没有选择项
(s/def ::thing (s/cat :a string? :b (s/+ number?)))
(s/def ::seq-of (s/+ ::thing))
(s/conform ::seq-of (list "foo" 1 "bar" 2 3 "qux" 4))
;=> [{:a "foo", :b [1]} {:a "bar", :b [2 3]} {:a "qux", :b [4]}]
这仅在第二或后续的 ::thing 中存在两个或更多数字时出现。
如果我把 :a 设置为非可选的,问题就会消失...
可能相关于
http://dev.clojure.org/jira/browse/CLJ-2003 ?