metosin / malli

High-performance data-driven data specification library for Clojure/Script.
Eclipse Public License 2.0
1.5k stars 211 forks source link

Incorrect coercion for alternatives of closed maps with optional keys #1112

Open opqdonut opened 3 weeks ago

opqdonut commented 3 weeks ago

Originally reported as metosin/reitit#632. Moving it here because it's a malli bug.

Similar to metosin/reitit#407, except that the maps are closed and contain optional keys. For example,

(malli.core/decode
  [:or
   [:map
    {:closed true}
    [:x {:optional true} int?]]
   [:map
    {:closed true}
    [:y {:optional true} keyword?]]]
  {:y :foo}
  malli.transform/strip-extra-keys-transformer)

should return {:y :foo} but actually returns {}.

opqdonut commented 3 weeks ago

Previously, #201