Welcome! Please see the About page for a little more info on how this works.

0 votes
in Spec by
Aliasing specs is a useful practice. For instance, a common ':myproj/name' spec may be used for two different keys e.g. ':myproj.user/name' and ':myproj.admin/name'.

However, when these are used in a spec, the ':via' path will include duplicates e.g. include ':myproj/name' twice.


1. clj -Srepro -Sdeps '{:deps {org.clojure/spec.alpha {:mvn/version "0.2.176"}}}'

(require '[clojure.spec.alpha :as s])
(s/def :myproj/name (s/and string? #(< 2 (count %))))
(s/def :myproj.user/name :myproj/name)
(s/def :myproj/user-args (s/cat :name :myproj.user/name))
(-> (s/explain-data :myproj/user-args [""]) ::s/problems pprint)

[{:path [:name],
  :pred (clojure.core/fn [%] (clojure.core/< 2 (clojure.core/count %))),
  :val "",
  :via [:myproj/user-args :myproj/user-args :myproj/name :myproj/name],
  :in [0]}]

Actual: the ':via' path for the problem is '[:myproj/user-args :myproj/user-args :myproj/name :myproj/name]'

Expected: I would have expected to see the spec ':myproj.user/name' in the ':via', since the ':myproj/user-args' spec is built in terms of ':myproj.user/name'.

1 Answer

0 votes
Reference: https://clojure.atlassian.net/browse/CLJ-2410 (reported by bbrinck)