From 566470c254ed858d59f3b08fee68f0dd2eb679bc Mon Sep 17 00:00:00 2001 From: Tommi Reiman Date: Sat, 24 Apr 2021 14:27:00 +0300 Subject: [PATCH] fixes #419 --- src/malli/core.cljc | 1 + test/malli/core_test.cljc | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/malli/core.cljc b/src/malli/core.cljc index be4cee466..fba45ffed 100644 --- a/src/malli/core.cljc +++ b/src/malli/core.cljc @@ -184,6 +184,7 @@ (defn -parse-entries [children {:keys [naked-keys lazy-refs]} options] (let [-parse (fn [e] (let [[[k ?p ?v] f] (cond (-reference? e) (if naked-keys [[e nil e] e]) + (and (= 1 (count e)) (-reference? (first e))) (if naked-keys [[(first e) nil (first e)] e]) (and (= 2 (count e)) (-reference? (first e)) (map? (last e))) (if naked-keys [(conj e (first e)) e]) :else [e (->> (-update (vec e) (dec (count e)) (-comp -form #(schema % options))) (keep identity) (vec))]) [p ?s] (if (or (nil? ?p) (map? ?p)) [?p ?v] [nil ?p]) diff --git a/test/malli/core_test.cljc b/test/malli/core_test.cljc index 0a8e2e214..5fd07be84 100644 --- a/test/malli/core_test.cljc +++ b/test/malli/core_test.cljc @@ -1754,16 +1754,18 @@ (deftest custom-registry-qualified-keyword-in-map-test (let [schema [:map {:registry {::id int? + ::location [:tuple :int :int] ::country string?}} ::id + [::location] [:name string?] [::country {:optional true}]]] (testing "Example with qualified keyword + optional, regular key" - (is (m/validate schema {::id 123 ::country "Finland" :name "Malli"}))) + (is (m/validate schema {::id 123 ::location [1 1] ::country "Finland" :name "Malli"}))) (testing "Optional qualified keyword is optional" - (is (m/validate schema {::id 123 :name "Malli"}))))) + (is (m/validate schema {::id 123 ::location [1 1] :name "Malli"}))))) (deftest simple-schemas (testing "simple schemas"