This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-08-11
Channels
- # aleph (7)
- # announcements (5)
- # beginners (58)
- # calva (20)
- # cider (10)
- # clj-kondo (4)
- # cljfx (5)
- # cljsrn (7)
- # clojure (29)
- # clojure-europe (11)
- # clojure-mexico (1)
- # clojure-norway (26)
- # clojure-uk (9)
- # clojurescript (1)
- # cursive (31)
- # datahike (22)
- # datomic (12)
- # duct (3)
- # fulcro (28)
- # helix (35)
- # hyperfiddle (28)
- # lsp (4)
- # malli (8)
- # midje (3)
- # music (2)
- # nbb (9)
- # nrepl (20)
- # off-topic (36)
- # polylith (3)
- # shadow-cljs (47)
- # sql (2)
- # testing (7)
- # vim (17)
- # xtdb (7)
^:-- if someone can show an real-life example where the value masking is still bad, please share (privately ok too). I guess if one has huge nested maps, masking each irrelevant key separately might still cause large values. Or a list of 100 entries with the last one in failure would cause 99 …
s, which might not be best. For maps, all the irrelevant keys could be optionally accumulated into single entry on …
as both key and value and for sequences, a …99
to show how many valids there are.
Hi, great work on Malli! I’m trying to figure out how I can use malli without duplicating attributes. Is the “What I want” syntax possible in some way?
;; What I have
[:map
[::order-id :int]
[::order-multiplier :int]
[::order-amount decimal?]]
;; What I want
[:map
[::order-id]
[::order-multiplier]
[::order-amount]]
(m/validate ::order-id "123")
;; => false
You can define a registry and register your schemas there. Here’s an inline example
(m/validate ::order-id "123" {:registry (merge
(m/default-schemas)
{::order-id :int
::order-multiplier :int
::order-amount decimal?})})
More info how to work with registries here https://github.com/metosin/malli#schema-registry
Cool thing. I created a custom “register function”.
(s/register ::api-key [:string {:min 1}])
in IntelliJ/cursive i resolved my function as clojure.spec.alpha/def — this way I can jump to the schema-definition of a namespaced keyword if there is a register call. 😄