Hi everyone,

I started exploring the clojure.spec "better user errors" thing and I'm 
having some trouble matching clojure.spec.alpha/problems inside
:clojure.spec.alpha/value in explain-data.

I'm trying to understand if there is currently a way of using problem to 
directly find the part of the value that is causing the issue independent of
the spec that failed.

For example given a spec :

(s/def ::spec-1 (s/map-of keyword? int?))

(-> (s/explain-data ::spec-1 {::k 8.8})
                         :clojure.spec.alpha/problems
                         first
                         :in)
=> [::k 1]   ;; which means the problem was with the value, not the key

but given a different spec for the same data :

(s/def ::k int?)
(s/def ::spec-2 (s/keys :req [::k]))

(-> (s/explain-data ::spec-2 {::k 8.8})
                         :clojure.spec.alpha/problems
                         first
                         :in)
=> [::k]

So the thing is that if you see a problem in [::k 1] you don't know if its 
the ::k value, or the value is a sequence and 
the problem is its element at pos 1.

Does it make sense or I'm missing something?

I'm trying with [org.clojure/clojure "1.9.0-alpha17"]

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to