merged the registries in.
quick poke on the recursive schemas, using :ref
:
(def ConsCell
[:maybe {:id :cons}
[:tuple int? [:ref :cons]]])
(m/explain ConsCell [1 [2 [3 [4 nil]]]])
; => nil
(m/explain ConsCell [1 [2 [3 [4]]]])
;{:schema [:maybe {:id :cons} [:tuple int? [:ref :cons]]],
; :value [1 [2 [3 [4]]]],
; :errors (#Error{:path [2 2 0 2 2 0 2 2 0 2],
; :in [1 1 1],
; :schema [:tuple int? [:ref :cons]],
; :value [4],
; :type :malli.core/tuple-size})}
ok, need to figure out how things like -accept
should work with recursive schemas as it’s eager (validation and explain can be both lazy). I guess need to keep a local book keeping not to walk over already walked :ref
s so that it doesn’t go to infinite loop.
Nice! :)
@ikitommi welcome to the club of infinite loop avoiders :-)
does it still work with cross recursion ? ping refers to pong, and pong refers to ping
does not work yet with mutual recursion, but I think we need :registry
schema anyway, like there is :definitions
for JSON Schma. Needed anyway for persisting the things. maybe something like:
(explain
[:registry
{:schemas [[:maybe {:id :ping} [:tuple [:eq "ping"] [:ref :pong]]]
[:maybe {:id :pong} [:tuple [:eq "pong"] [:ref :pong]]]]}
[:ref :pong]]
["ping" ["pong" ["ping" nil]]])
; => true
btw, a colourful discussion at the old draft PR: https://github.com/metosin/malli/pull/117
I've got
:closure-defines {malli.registry/type "custom"}
in my shadow-cljs.edn, but still seeing error:
can't set default registry {:type "default"}
Any ideas what I may be forgetting?oh, that's weird - some kind of caching bug; forcing a recompile (after it showed the error) and it went away. ¯\(ツ)/¯
The new registry setup allows for easier bootstrapping custom code. :thumbsup:
it doesn’t look like the new first class :string
is bundled with the latest reitit [metosin/reitit-malli "0.5.2"]
is there reason for this or am I missing something?
metosin/reitit-malli
on clojars is dependent on malli 0.0.1-SNAPSHOT
- theoretically, last version was uploaded yesterday, but maybe you have some caching issues? (I think clojure deps caches any snapshot locally for 24(?) hours). Perhaps try to update your deps to depend directly on latest malli from master?