Skip to content

Commit

Permalink
fixes #419
Browse files Browse the repository at this point in the history
  • Loading branch information
ikitommi committed Apr 24, 2021
1 parent ccabd0b commit 566470c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/malli/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
6 changes: 4 additions & 2 deletions test/malli/core_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 566470c

Please sign in to comment.