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?
decoding is a process of transforming values from external formats into valid clojure data. Parsing returns the parse trees.
@ingesol what version are you using. CHANGELOG says it's fixed in 0.5.0
@ikitommi hmm, I thought I was on 0.5.2 or something, will check
Very happy to be wrong, I was on 0.4.0. Thanks 🙂
Aaaand it works! Thanks for great help, as always