This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-06-04
Channels
- # announcements (13)
- # asami (68)
- # babashka (19)
- # beginners (51)
- # calva (4)
- # cider (3)
- # clj-kondo (13)
- # clojure (161)
- # clojure-australia (3)
- # clojure-europe (21)
- # clojure-nl (4)
- # clojure-spec (9)
- # clojure-sweden (13)
- # clojure-uk (9)
- # clojured (14)
- # clojurescript (7)
- # conjure (4)
- # cursive (16)
- # data-science (2)
- # datalog (1)
- # figwheel-main (7)
- # graalvm (18)
- # helix (14)
- # introduce-yourself (1)
- # jackdaw (9)
- # jobs (1)
- # kaocha (1)
- # malli (8)
- # meander (8)
- # off-topic (7)
- # pathom (11)
- # proletarian (3)
- # shadow-cljs (29)
- # tools-deps (106)
- # xtdb (8)
I’ve been trying to get this to work, but cannot figure out what is going on. I’m expecting the :type
value to be converted to a string:
(m/encode
[:schema {:registry
{::node [:multi {:dispatch :type
:decode/string #(update % :type keyword)}
[:malli.core/default
[:map
[:type :keyword]]]]}}
::node]
{:type :doc}
mt/string-transformer)
=> {:type :doc}
If I replace :malli.core/default
with :doc
, I get the expected string-coerced keyword
{:type "doc"}
Also, the schema has a local registry in order to be able to have nodes within nodes. If I remove the wrapping, the following also works:
(m/encode
[:map
[:type :keyword]]
{:type :doc}
mt/string-transformer)
=> {:type "doc"}
What's the difference between parsing data and decoding data? My sense is that parse
is similar to spec's conform
, whereas decode
is more about transformation - is that generally right?
✅ 2
decoding is a process of transforming values from external formats into valid clojure data. Parsing returns the parse trees.
@U055NJ5CC hmm, I thought I was on 0.5.2 or something, will check