Fork me on GitHub
#malli
<
2023-10-21
>
roklenarcic12:10:14

I get these kind of spec failures:

:in [0 375 :roklenarcic.security/underlying :roklenarcic.security/category],
   :message "missing required key",
   :path [0 0 :roklenarcic.security/underlying 0 :roklenarcic.security/category],
   
What’s the difference between :in and :path . In this case the actual element that is wrong is at 375, so why is path index [0 0 ….?

ikitommi18:10:28

e.g. :path is a path in Schema, not value.

mpoffald00:10:37

If :in is the path in the value, does that make this a bug in path->in?

(require '[malli.core :as m ]) 
  (def my-schema
    (m/schema [:orn
               [:a-branch [:map [:a :int]]]
               [:b-branch [:map [:b :int]]]]))   

  (let [{:keys [errors schema]} (m/explain my-schema {:a "2"})]
    (mu/path->in schema (:path (first errors))))
;;=>
[:a-branch :a] 

mpoffald00:10:38

my value doesn’t have an :a-branch key

ikitommi05:10:03

Oh, it’s a bug.

ikitommi05:10:31

@UNCHWPV4Y could you file an issue out of this? should be a simple fix. I think same applies to :altn and :catn.

👍 1
mpoffald00:10:37

If :in is the path in the value, does that make this a bug in path->in?

(require '[malli.core :as m ]) 
  (def my-schema
    (m/schema [:orn
               [:a-branch [:map [:a :int]]]
               [:b-branch [:map [:b :int]]]]))   

  (let [{:keys [errors schema]} (m/explain my-schema {:a "2"})]
    (mu/path->in schema (:path (first errors))))
;;=>
[:a-branch :a]