From df629394a794d726806bb28804be5a833278a81c Mon Sep 17 00:00:00 2001 From: Tommi Reiman Date: Wed, 28 Aug 2024 15:45:50 +0300 Subject: [PATCH] fix review comment --- src/malli/generator.cljc | 2 +- test/malli/generator_test.cljc | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/malli/generator.cljc b/src/malli/generator.cljc index 171d3695e..078b4c85e 100644 --- a/src/malli/generator.cljc +++ b/src/malli/generator.cljc @@ -172,7 +172,7 @@ #(map (fn [[k :as e]] (cond-> e (not= ::m/default k) - (update 2 mu/merge [:map [dispatch [:= k]]]))) %) + (update 2 mu/merge [:map [dispatch [:= nil k]]]))) %) (m/options schema))))) (defn -multi-gen [schema options] diff --git a/test/malli/generator_test.cljc b/test/malli/generator_test.cljc index bea04c348..9e23e7909 100644 --- a/test/malli/generator_test.cljc +++ b/test/malli/generator_test.cljc @@ -1116,4 +1116,11 @@ ["duck" :map] [::m/default [:= "boss"]]]] (is (every? #{{:type "duck"} "boss"} (mg/sample schema))) + (is (every? (m/validator schema) (mg/sample schema))))) + + (testing "works with nil & {} too" + (let [schema [:multi {:dispatch :type} + [nil :map] + [{} :map]]] + (is (every? #{{:type nil} {:type {}}} (mg/sample schema))) (is (every? (m/validator schema) (mg/sample schema))))))