This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-02-23
Channels
- # announcements (1)
- # babashka (68)
- # babashka-sci-dev (12)
- # beginners (36)
- # biff (22)
- # calva (20)
- # clerk (1)
- # clj-on-windows (7)
- # clojure (27)
- # clojure-conj (8)
- # clojure-denmark (2)
- # clojure-europe (141)
- # clojure-france (1)
- # clojure-italy (4)
- # clojure-nl (1)
- # clojure-uk (2)
- # clojurescript (7)
- # conjure (8)
- # core-async (111)
- # cursive (3)
- # datahike (4)
- # datalevin (18)
- # events (9)
- # gratitude (4)
- # guix (2)
- # helix (3)
- # hyperfiddle (62)
- # introduce-yourself (2)
- # kaocha (4)
- # london-clojurians (3)
- # lsp (7)
- # malli (34)
- # membrane (1)
- # nbb (9)
- # polylith (4)
- # portal (6)
- # reagent (4)
- # releases (2)
- # remote-jobs (4)
- # shadow-cljs (30)
- # sql (2)
- # tools-deps (58)
- # xtdb (9)
Q: I’m using instrumented fns and they are logging invalid data correctly but I’m drowning in logs from this in some cases. Is there a way to make an invalid fn input throw an exception i.e. halt on first bad value detected instead of continuing?
Hmm, I see the default report behaviour is m/-fail so it must be my code. I’m using core.async with the go-try macro from org.clojars.akiel/async-error
but I’m not using a global/default registry so that’s a bit different to the way the docs show it
Ok, then you can instrument it with a custom report fn. https://github.com/metabase/metabase/blob/master/src/metabase/util/malli.cljc#L93-L95
oh, I found my mistake. I was using pretty/reporter when I should have been using pretty/thrower
No rush. I was wondering if there’s a release planned that includes the fixes for https://github.com/metosin/malli/issues/819
Hey guys. I'm looking at the screenshot in the README (https://raw.githubusercontent.com/metosin/malli/master/docs/img/malli-defn.png) and it's precisely what I'm trying to achieve.
I have this:
(m/=> qid-str [:=> [:cat :int] :int])
(defn qid-str [version-number-list] (str/join "." version-number-list))
(qid-str [1 2 3 4])
But it's not doing anything. How do I hook up the schema validation into the fn execution, just like it's in the screenshot?
Where does (dev/start)
come from?
That sounds like some HTTP thing. I just have a very simple CLI app.
Hey Jakub. I just went through this earlier in the week and it was rather confusing for me (but I got there!).
Here’s what I (and perhaps you) need(ed) to know:
1. malli.instrument/collect!
needs to be called to find all of the function annotations in the namespaces you tell it, or the current namespace by default.
2. malli.instrument/instrument!
then rewrites the functions to include the validation you’re looking for.
3.
will do both of these things for you.
4. It also installs a watcher that will do that rewriting process automatically when m/=>
is evaluated.
5. Contrary to the docs, the order of the function and the m/=>
matters (a lot) for this case. If you eval the m/=>
first, and then the function (as will happen in your code), the function will be redefined without the validation.
@U0CV48L87 thanks Cameron, that's very helpful.
One more gotcha to watch out for: if namespaces aren’t loaded (yet) then they’re not going to get instrumented. It’s less of a problem when using
, since you can work around it using m/=>
, it can be a headache in tests or if you’re trying to use the function metadata annotations.
I haven’t gotten to a setup I’m entirely happy with for both interactive development and testing.
Using the macro annotation form should solve all of the issues, but I was hesitate to adopt it first.
Good to know. It's a lot to digest (as I'm generally fairly new to Clojure, though not to programming). Malli does look great.
Oh wow good note on the namespaces!