Skip to content
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

Open
tomconnors opened this issue Nov 18, 2024 · 1 comment
Open

Clarify and maybe change unparse behavior #1123

tomconnors opened this issue Nov 18, 2024 · 1 comment

Comments

@tomconnors
Copy link

As posted on slack, data equal to the result of malli.core/parse cannot be unparsed.

(def int-or-string [:orn [:int :int] [:str :string]])

(malli.core/parse int-or-string 1) ;; -> [:int 1]

(= [:int 1] (malli.core/parse int-or-string 1)) ;; -> true

(malli.core/unparse int-or-string [:int 1]) ;=> :malli.core/invalid

(->> 1
     (malli.core/parse int-or-string)
     (malli.core/unparse int-or-string)) ;; => 1

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.

@ikitommi
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

2 participants