Fork me on GitHub
#malli
<
2020-06-18
>
ikitommi04:06:42

merged the registries in.

ikitommi04:06:06

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})}

Vincent Cantin05:06:20

does it still work with cross recursion ? ping refers to pong, and pong refers to ping

ikitommi04:06:27

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 :refs so that it doesn’t go to infinite loop.

Vincent Cantin05:06:45

@ikitommi welcome to the club of infinite loop avoiders :-)

ikitommi05:06:58

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

ikitommi05:06:33

btw, a colourful discussion at the old draft PR: https://github.com/metosin/malli/pull/117

pithyless16:06:49

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?

pithyless16:06:37

oh, that's weird - some kind of caching bug; forcing a recompile (after it showed the error) and it went away. ¯\(ツ)

pithyless16:06:28

The new registry setup allows for easier bootstrapping custom code. :thumbsup:

👍 3
jkent17:06:18

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?

pithyless18:06:04

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?