Open tomconnors opened 1 week ago
result of parse is actually a MapEntry
. Clojure =
matches it to vector of two elements. See https://github.com/metosin/malli/blob/master/src/malli/impl/util.cljc#L8-L9. But, I see this being a problem.
To clarify, here's how to get the original example to work:
(malli.core/unparse int-or-string (malli.impl.util/-tagged :int 1)) ; => 1
;; OR
(malli.core/unparse int-or-string (clojure.lang.MapEntry. :int 1)) ; => 1
I agree that this is unwieldy. It would be easy to changed tagged?
to accept vectors of size two, but I'm not sure what implications this would have. Are people passing in arbitrary data to unparse
? Is there some possibility for confusion?
After thinking about it for a bit, I think this is a safe change. I've prepared a PR (#1140).
As posted on slack, data equal to the result of
malli.core/parse
cannot be unparsed.I have some data in my schema's parsed format, which was not produced by
parse
, but which I would like to unparse. It appears that's not currently possible.