Skip to content

Commit

Permalink
fix printing
Browse files Browse the repository at this point in the history
  • Loading branch information
frenchy64 committed Jul 17, 2024
1 parent 07373ad commit 11b6e22
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
13 changes: 9 additions & 4 deletions src/malli/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@
(if (into-schema? ?schema)
?schema
(some-> (mr/-schema registry ?schema)
(-lookup-into-schema options))) )))
recur)))))

(defn -properties-and-options [properties options f]
(if-let [r (:registry properties)]
Expand Down Expand Up @@ -1692,8 +1692,13 @@
(-check-children! type properties children 1 1)
(let [children (-vmap #(schema % options) children)
child (nth children 0)
form (delay (or (and (empty? properties) (or id (and raw (-form child))))
(-simple-form parent properties children -form options)))
form (delay (let [no-props? (empty? properties)]
(or (if id
(if no-props?
id
[id properties]))
(and no-props? raw (-form child))
(-simple-form parent properties children -form options))))
cache (-create-cache options)]
^{:type ::schema}
(reify
Expand Down Expand Up @@ -2192,7 +2197,7 @@
;; =m/deref=>
;; [:map-of :int :any]
(-fail! ::references-do-not-support-children {:schema ?schema})
(-pointer ?schema (schema ?schema' options) properties options))
(-pointer v0 (schema ?schema' options) properties options))
(-fail! ::invalid-schema {:schema ?schema}))))
:else (if-let [?schema' (and (-reference? ?schema) (-lookup ?schema options))]
(-pointer ?schema (schema ?schema' options) nil options)
Expand Down
15 changes: 13 additions & 2 deletions test/malli/registry_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,19 @@
(register! :str (m/-string-schema))
(is (true? (m/validate :str "kikka" {:registry registry})))
(register! ::foo (m/schema [:tuple :int]))
(is (m/schema ::foo {:registry registry}))
(is (m/schema [::foo {:doc ""}] {:registry registry})))))
(is (= ::foo
(-> (m/schema ::foo {:registry registry})
m/form)))
(is (= [::foo {:doc ""}]
(-> (m/schema [::foo {:doc ""}] {:registry registry})
m/form)))
(register! ::bare [:tuple :int])
(is (= ::bare
(-> (m/schema ::bare {:registry registry})
m/form)))
(is (= [::bare {:doc ""}]
(-> (m/schema [::bare {:doc ""}] {:registry registry})
m/form))))))

(deftest composite-test
(let [registry* (atom {})
Expand Down

0 comments on commit 11b6e22

Please sign in to comment.