This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-09-08
Channels
- # announcements (9)
- # babashka (17)
- # beginners (26)
- # biff (2)
- # calva (5)
- # cider (11)
- # clara (6)
- # clojure (48)
- # clojure-europe (34)
- # clojure-nl (1)
- # clojure-norway (34)
- # clojure-uk (2)
- # clojurescript (22)
- # clr (11)
- # code-reviews (5)
- # conjure (3)
- # datomic (26)
- # emacs (14)
- # fulcro (10)
- # hyperfiddle (70)
- # lsp (34)
- # malli (5)
- # missionary (5)
- # off-topic (34)
- # releases (1)
- # shadow-cljs (19)
- # tree-sitter (1)
- # xtdb (25)
How can I use schemas from my custom registry in malli instrumentation?
I have a namespace with a
registry
var, which is a mr/composite-registry
. When I pass {:registry registry}
as options to Malli functions, this works as expected.I now want to annotate functions like this, and use
:
(defn my-func
{:malli/schema [:=> [:cat :custom-schema] :any]}
[val])
(mr/set-default-registry! registry)
before calling start!
, and using [:=> {:registry registry} [:cat :custom-schema] :any]
, but both did not work (throws :invalid-schema
). I also tried (! {:registry registry})
.(defn my-func
{:malli/schema (malli.core/schema [:=> [:cat :custom-schema] :any] {:registry registry})}
[val])
I was hoping to keep my metadata as plain data, without needing to require malli.core
.
Argh. I found out that my custom start!
that calls set-default-registry!
is actually never called. It does work.
Sorry for the noise 😇
Out of curiosity: where/when do you call set-default-registry
? I tried using the default registry lately but moved away from it when I hit some load ordering problems.
In development, I just call set-default-registry!
followed by malli.dev/start!
.
My custom registry is a composite-registry
of default-schemas
and mutable-registry
. The mutable registry points to an atom where I assoc my schemas to. I first used default-registry
instead of default-schemas
, which does not work when using set-default-registry!
because of infinite recursion.
My production code does not change the default-registry, but passes the custom registry using the :registry
option