Fork me on GitHub

is there a way to spec a map using a coll of types/keywords (instead of a single type/keyword as with multi-spec)? the idea is that all specs corresponding to matched types are merged and used to validate the map


what i have is { ::types [:first :second] } and what i'm looking for is a way to create something like a multi-spec which dispatches on the values in the coll corresponding to ::types and which will build a spec like (s/merge ::first ::second)


(defmulti types ::types) (defmethod types :default [{::keys[types]}]) (eval (apply s/merge types)))` Some lke this?


Hi. I have a vector of s/keys specs and I would like to merge them, without eval. As s/merge is a macro, I guess I should use merge-spec-impl?


I’m trying to combine stuff with s/merge. Is this intentional or a bug?

(s/explain any? {:x 1, :y 2})
; Success!

(s/explain (s/merge any?) {:x 1, :y 2})
; val: {:x 1, :y 2} fails predicate: any?


ok, this works thou:

(s/explain (s/merge (s/spec any?)) {:x 1, :y 2})
; Success!


But as the s/spec is macro too, with my arbitrary vector-of-specs input, I would have to call s/spec-impl instead to avoid eval and figure out the forms somehow. Any news on the new functional core for clojure.spec?