This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-02-10
Channels
- # announcements (6)
- # babashka (38)
- # beginners (85)
- # biff (3)
- # calva (2)
- # cider (11)
- # clerk (14)
- # clj-kondo (6)
- # clj-on-windows (27)
- # clj-together (2)
- # cljsrn (18)
- # clojure (106)
- # clojure-austin (1)
- # clojure-belgium (1)
- # clojure-europe (19)
- # clojure-nl (1)
- # clojure-norway (9)
- # clojure-uk (2)
- # clr (2)
- # cryogen (1)
- # cursive (10)
- # datahike (3)
- # datavis (2)
- # datomic (15)
- # emacs (7)
- # graalvm (10)
- # graphql (20)
- # gratitude (1)
- # hyperfiddle (1)
- # improve-getting-started (23)
- # joyride (24)
- # london-clojurians (1)
- # lsp (22)
- # malli (4)
- # matcher-combinators (3)
- # membrane (13)
- # off-topic (1)
- # pathom (24)
- # polylith (9)
- # react (31)
- # reagent (9)
- # releases (1)
- # remote-jobs (1)
- # reveal (3)
- # shadow-cljs (50)
- # spacemacs (3)
- # specter (5)
- # xtdb (5)
is there an established "best practice" re: calling m/schema
or not in your schema defs? E.g.
(def foo-schema
[:map ...])
vs
(def foo-schema
(m/schema
[:map ...]))
So far I've been writing the latter to get fail-fast behavior when a schema is invalid, but it's more verbose and forces the use of malli.util
fns to transform/combine schemas. And AFAIK there's only a small performance benefit to calling m/schema
thanks to Malli's caching. So I'm not sure what to pick as a default.One suggestion could be to write a macro which defs and validates a schema but defines the value of the var as the original data as long as validation succeeds
Or a function that does the same and just use that instead of m/schema in your second example
I could certainly do that, although it's still a little more verbose. And I'm not even sure I need it given that my data schemas will end up getting validated at ns load time via the function schemas that use them anyway.
So I guess my only remaining question is about performance. Is it true that there's no meaningful performance benefit to calling m/schema
any more?