This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-04-21
Channels
- # announcements (12)
- # aws (1)
- # babashka (82)
- # beginners (89)
- # calva (8)
- # cider (20)
- # clj-kondo (1)
- # clojars (9)
- # clojure (120)
- # clojure-australia (3)
- # clojure-europe (14)
- # clojure-france (24)
- # clojure-germany (3)
- # clojure-italy (16)
- # clojure-nl (1)
- # clojure-spec (3)
- # clojure-uk (22)
- # clojurescript (26)
- # cursive (38)
- # datascript (1)
- # emacs (10)
- # events (1)
- # helix (7)
- # jackdaw (5)
- # jobs-discuss (37)
- # lambdaisland (10)
- # malli (20)
- # meander (2)
- # off-topic (15)
- # pathom (42)
- # quil (1)
- # re-frame (38)
- # react (2)
- # reitit (2)
- # reveal (9)
- # rewrite-clj (3)
- # ring (5)
- # shadow-cljs (84)
- # spacemacs (1)
- # tools-deps (23)
- # vim (8)
- # vscode (1)
Let's not forget https://github.com/kwrooijen/gungnir
I'm just trying malli for the first time today, and it looks pretty great already
one thing I didn't quite understand though, if I annotate a function with (m/=> ...
is there a way to actually force that check at runtime to make it fail when the schema doesn't match?
I only see that related with generating a clj-kondo config, which is great but I thought that run-time assertions would be also there, even if disabled by default maybe
https://github.com/metosin/malli/issues/349 but @setzer22 has a working implementation https://github.com/setzer22/malli-instrument
Yes, I've been using my implementation for a couple of weeks now 👍 The base features are working, but sometimes malli has trouble generating human readable descriptions of errors
ah nice, yeah no rush was just wondering if I missed something from the docs
@setzer22 yes, there is an open PR about robust humanized errors. Few combinations that don’t work, but the idea to fix it seems legit.
another thing I noticed is that there isn't a way to just throw an exception if something fails to validate. I ended up with something like
(let [my-map ...
errors (m/explain schema my-map)]
(if (nil? errors) my-map (throw (ex-info "validation failed" errors)))
but isnt't there an easier way to do that?There wasn't even an issue so I made one https://github.com/metosin/malli/issues/420
Hmm hard to make an efficient assert that makes the validator
and explainer
behind the scenes. Especially Cljs would be tricky.
mm maybe you don't always need the explainer
would be nice I guess but not sure it needs to be the default
Thanks for creating the issue! it must have slipped my mind. Do you mean caching a validator at the assert's compile time? I would be worried about the validator then going out of sync when you redefine the schema during dev time
Maybe the *assert*
dynamic var could have 3 levels:
• runtime validate
(slowest but correct)
• compile-time validator
(more efficient, use if schemas are fixed)
• compiles to nil