Skip to content

Commit

Permalink
Fixes #196
Browse files Browse the repository at this point in the history
  • Loading branch information
ikitommi committed Apr 16, 2020
1 parent f8e3890 commit 8b2aa9f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/malli/provider.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,15 @@
([stats]
(schema stats nil))
([{:keys [types] :as stats} options]
(if (= 1 (count (keys types)))
(cond
(= 1 (count (keys types)))
(let [type (-> types keys first)]
(case type
:value (-value-schema (type types))
(:set :vector :list :sequential) [type (-> types type :values (schema options))]
:map (-map-schema (type types) options)))
(into [:or] (map (fn [[type]] (schema (update stats :types select-keys [type]) options)) types)))))
(nil? types) (m/schema any?)
:else (into [:or] (map (fn [[type]] (schema (update stats :types select-keys [type]) options)) types)))))

(defn provide
([xs]
Expand Down
2 changes: 2 additions & 0 deletions test/malli/provider_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
[qualified-keyword? [::kikka ::kukka]]
[uuid? [#?(:clj (java.util.UUID/randomUUID) :cljs (random-uuid))]]
[inst? [#?(:clj (java.util.Date.) :cljs (js/Date.))]]
[any? []]

[[:vector keyword?] [[:kikka] [:kukka :kakka]]]
[[:list symbol?] [(list 'kikka) (list 'kukka 'kakka)]]
[[:sequential symbol?] [(seq ['kikka]) (seq ['kikka 'kakka])]]
[[:set string?] [#{"a" "b"} #{"c"}]]
[[:vector [:list [:set int?]]] [[(list #{1})]]]
[[:vector any?] [[]]]

[[:map
[:id string?]
Expand Down

0 comments on commit 8b2aa9f

Please sign in to comment.