-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarify and maybe change unparse
behavior
#1123
Comments
result of parse is actually a |
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 |
After thinking about it for a bit, I think this is a safe change. I've prepared a PR (#1140). |
Using a MapEntry was confusing users, because it printed like a vector, but you couldn't give a vector to unparse. The current method of using MapEntry was broken for weird schemas: ``` (def schema [:or [:tuple :string :keyword] [:orn ["any" :keyword]]]) (->> (m/parse schema :any) (m/unparse schema)) ; => ["any" :any] ; should've been :any ``` Changes the parse behaviour for (at least) :orn, :altn and :multi Some place (like the entry parsers) used miu/-tagged to generate MapEntry values. These use sites now use the new miu/-entry. This keeps the surface area of this change a lot smaller since we don't need to touch all the map entry logic. fixes #1123 replaces #1140
A new solution that uses a custom record for parse output in #1150 |
Using a MapEntry was confusing users, because it printed like a vector, but you couldn't give a vector to unparse. The current method of using MapEntry was broken for weird schemas: ``` (def schema [:or [:tuple :string :keyword] [:orn ["any" :keyword]]]) (->> (m/parse schema :any) (m/unparse schema)) ; => ["any" :any] ; should've been :any ``` Changes the parse behaviour for (at least) :orn, :altn and :multi Some place (like the entry parsers) used miu/-tagged to generate MapEntry values. These use sites now use the new miu/-entry. This keeps the surface area of this change a lot smaller since we don't need to touch all the map entry logic. fixes #1123 replaces #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.The text was updated successfully, but these errors were encountered: