nubank / matcher-combinators

Library for creating matcher combinator to compare nested data structures
Other
467 stars 23 forks source link

`seq-of` matcher #149

Closed dchelimsky closed 1 year ago

dchelimsky commented 4 years ago

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))))
philomates commented 1 year ago

giving it a shot in https://github.com/nubank/matcher-combinators/pull/191, what do you think?