评论由:pbrown 提供
我发现另一个额外的嵌套案例,当时在序列中重复一个或多个元素,并在开始或结束时有一个可选元素,其中该元素的谓词还匹配另一端的元素
user=> (s/conform (s/+ (s/cat :k any? :v (s/? any?))) [:a 1 :b 2]) [{:k :a, :v 1} [{:k :b, :v 2}]]
期望得到
`
[{:k :a, :v 1} {:k :b, :v 2}] `
以下提供了期望的结果
user=> (s/conform (s/+ (s/cat :k any? :v (s/? any?))) [:a 1 :b]) [{:k :a, :v 1} {:k :b}] user=> (s/conform (s/+ (s/cat :k keyword? :v (s/? int?))) [:a 1 :b 2]) [{:k :a, :v 1} {:k :b, :v 2}] user=> (s/conform (s/* (s/cat :k any? :v (s/? any?))) [:a 1 :b 2]) [{:k :a, :v 1} {:k :b, :v 2}]