(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中包含 2+ 个数字时会显示
如果将 :a 设置为非可选的话,问题就会消失...
可能与
http://dev.clojure.org/jira/browse/CLJ-2003 相关?