Fork me on GitHub
#clojure-spec
<
2017-08-13
>
misha09:08:56

is there something out of the box for getting conforming subset of a data structure? e.g.

(s/def ::foo (s/keys :req-un [::a ::b]))
(s/valid? ::foo {:a 1 :b 2 :c 3})  ;; => true
(conformed-part ::foo {:a 1 :b 2 :c 3})  ;; => {:a 1 :b 2} (only keys from ::foo spec are kept)

Alex Miller (Clojure team)16:08:48

in this case, the data structure does conform to the spec

Alex Miller (Clojure team)16:08:00

because s/keys supports open maps

Alex Miller (Clojure team)16:08:56

so, essentially no. there is something here Rich is considering adding but not sure if and when that will happen