hello, is there a place that explains how to properly implement the s/Spec protocol? I'm not sure about some of the methods, also, is there a place that explains the :path, :via and :in parts of the spec problems? (I see in the spec docs it talks about but doesn't mention exact those keys)
they are all "paths", but :in is data, :path is tags, and :via is specs
No, we don't really consider that public api
But if you have a question I'll try to answer it :)
mostly about the :path, :via and :in, what is expect on each and what makes it different from one another?
there is some info at https://clojure.org/guides/spec#_explain
although those are words in the error message that map to the keys:
• :path - vector of keyword tag "path" segments (usually from :or, :cat, :alt, etc)
• :via - vector of spec names from the root
• :in - vector of data values from root to failing value (will be omitted if it's the root value)
there's an implicit tree being recursively walked here. the nodes are specs (name = :via element). Each edge has a name (:path element) and the value to validate (:in element)
in some cases, some of those are synthetic, created by the spec
the examples I'm seeing are mostly related to s/keys, where I see things like this:
(s/def ::a string?)
(s/explain-data (s/keys :req [::a]) {::a 1})
{:clojure.spec.alpha/problems ({:path [:com.piposaude.model.bulk-insert-test/a],
:pred clojure.core/string?,
:val 1,
:via [:com.piposaude.model.bulk-insert-test/a],
:in [:com.piposaude.model.bulk-insert-test/a]}),
:clojure.spec.alpha/spec #object[clojure.spec.alpha$map_spec_impl$reify__1998
0xabd19ae
"clojure.spec.alpha$map_spec_impl$reify__1998@abd19ae"],
:clojure.spec.alpha/value {:com.piposaude.model.bulk-insert-test/a 1}}in this case all :path, :via and :in are the same value
but from what I got to you, is like:
:in - path from root
:path - local path
:via - specs in the process
is that a fair simplification of them?
and do you have examples that can clear up the distinction?