Skip to content

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

Open
@escherize

Description

@escherize

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions