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

When parsing, the parsed value is passed into validation functions, causing failure to parse even on schemas that validate. #1166

Open
escherize opened this issue Jan 28, 2025 · 0 comments · May be fixed by #1167

Comments

@escherize
Copy link
Contributor

It seems like this is not the intended behavior, but here's what I am seeing locally:

These print different things, but that's not a big problem:

(mc/validate [:and [:catn ["a" :int] ["b" :keyword]]
              [:fn (fn [x] (prn x) true)]]
             [3 :x])
;; prints: [3 :x]
;; => true

(mc/parse [:and [:catn ["a" :int] ["b" :keyword]]
           [:fn (fn [x] (prn x) true)]]
          [3 :x])
;; prints: {"a" 3, "b" :x}
;; => {"a" 3, "b" :x}

The problem I'm hitting is when we actually try to validate these things with the attached :fn schema:

(mc/validate [:and [:catn ["a" :int] ["b" :keyword]]
              [:fn vector?]]
             [3 :x])
;; true

(mc/parse [:and [:catn ["a" :int] ["b" :keyword]]
           [:fn vector?]]
          [3 :x])
;; => :malli.core/invalid 😢 

I sort of can work around it by checking for e.g. (if it's a map with these keys, then it passes validation). but that's not really ideal.

@frenchy64 frenchy64 linked a pull request Jan 28, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant