This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-05-08
Channels
- # announcements (1)
- # asami (3)
- # babashka (51)
- # beginners (86)
- # chlorine-clover (1)
- # cider (18)
- # clara (5)
- # clj-kondo (6)
- # cljsrn (6)
- # clojure (2)
- # clojure-europe (18)
- # clojure-uk (1)
- # clojurescript (57)
- # clojureverse-ops (2)
- # code-reviews (9)
- # cryogen (11)
- # depstar (5)
- # jackdaw (2)
- # malli (8)
- # nrepl (2)
- # off-topic (66)
- # practicalli (3)
- # reitit (6)
- # shadow-cljs (83)
- # sql (4)
- # vim (24)
- # xtdb (4)
Is it possible to get malli to coerce blank strings ""
into the :default
value? Example:
(m/decode
[:map [:x {:default 0} int?]]
{:x ""}
(mt/transformer
mt/default-value-transformer
mt/string-transformer))
Should result in {:x 0}
Eh, never mind. I’m thinking this isn’t a great idea. I can just strip empty strings from my data before sending it into malli for coercion. I think that’s clearer and less error-prone.
I noticed that the the schema:
[:schema {:registry {::cons [:maybe [:tuple pos-int? [:ref ::cons]]]}}
::cons]
doesn't work on http://malli.io (it doesn't produce DOT output or JSON schema)
while
[:schema
{:registry {"ConsCell" [:maybe [:tuple :int [:ref "ConsCell"]]]}}
"ConsCell"]
this one does work.
In my applications I would like to use fully qualified keyword schemas (RefSchemas) is there a way to get the transformers to work without walking the schema ahead of time and converting all fully qualified keywords to strings?@danvingo it's a malli-sci-thing. I think one needs to define what is the current ns to sci so that ::cons
works. Try :user/cons
and it should work. I think @borkdude knows the answer how to make the ::
work with sci...
thanks Tommi - using :user/cons worked. I was also seeing some issues in a local repl regarding refschemas and dot. I'll try to get minimal repro
Welcome to xterm-sci.
user=> ::foo
:user/foo
user=>
https://babashka.org/xterm-sci/