Skip to content

Commit 3256139

Browse files
committed
bit shorter
1 parent 70c0b95 commit 3256139

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

src/malli/core.cljc

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2086,11 +2086,11 @@
20862086
(-check-children! :ref properties children 1 1)
20872087
(when-not (-reference? ref)
20882088
(-fail! ::invalid-ref {:ref ref}))
2089-
(let [child (delay (or (mr/-schema (-registry options) ref)
2090-
(when-not allow-invalid-refs
2091-
(-fail! ::invalid-ref {:type :ref, :ref ref}))))
2092-
_ (when-not lazy @child)
2093-
rf (-memoize (fn [] (schema @child options)))
2089+
(let [?schema (delay (or (mr/-schema (-registry options) ref)
2090+
(when-not allow-invalid-refs
2091+
(-fail! ::invalid-ref {:type :ref, :ref ref}))))
2092+
_ (when-not lazy @?schema)
2093+
rf (-memoize (fn [] (schema @?schema options)))
20942094
children (vec children)
20952095
form (delay (-simple-form parent properties children identity options))
20962096
cache (-create-cache options)
@@ -2106,24 +2106,19 @@
21062106
id (-identify-ref-schema this)]
21072107
(if lazy
21082108
(let [rv (ref-validators id)
2109-
vol (or rv (volatile! nil))
2110-
reg (when-not rv (-registry options))]
2109+
vol (or rv (volatile! nil))]
21112110
(fn [x]
21122111
(if-let [f @vol]
21132112
(f x)
2114-
(let [s @child
2115-
f (binding [*ref-validators* (assoc ref-validators id vol)]
2116-
(-validator s))]
2113+
(let [f (binding [*ref-validators* (assoc ref-validators id vol)]
2114+
(-validator (schema @?schema options)))]
21172115
(vreset! vol f)
21182116
(f x)))))
21192117
(if-some [vol (ref-validators id)]
21202118
#(@vol %)
21212119
(let [vol (volatile! nil)
2122-
s (if-let [s @child]
2123-
(schema s options)
2124-
(-fail! ::invalid-ref {:type :ref, :ref ref}))
21252120
f (binding [*ref-validators* (assoc ref-validators id vol)]
2126-
(-validator s))]
2121+
(-validator (schema @?schema options)))]
21272122
(vreset! vol f)
21282123
f)))))
21292124
(-explainer [_ path]

0 commit comments

Comments
 (0)