评论者: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}]