Skip to content

Commit

Permalink
fix review comment
Browse files Browse the repository at this point in the history
  • Loading branch information
ikitommi committed Aug 28, 2024
1 parent 0bc3fa4 commit df62939
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/malli/generator.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
7 changes: 7 additions & 0 deletions test/malli/generator_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -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))))))

0 comments on commit df62939

Please sign in to comment.