matcher-combinators icon indicating copy to clipboard operation
matcher-combinators copied to clipboard

`seq-of` matcher

Open dchelimsky opened this issue 5 years ago • 0 comments

Add a matcher that matches a non-empty sequence of elements that match a supplied matcher, e.g.

(match? (seq-of {:name string? :id uuid?})
        [{:name "Michael"
         :id    #uuid "c70e35eb-9eb6-4e3d-b5da-1f7f80932db9"}])

This impl works, but the resulting failure message leaves something to be desired:

(defn seq-of [matcher] (fn [coll] (and (seq coll) (every? (partial matcher-combinators.standalone/match? matcher) coll))))

dchelimsky avatar Sep 14 '20 22:09 dchelimsky