Skip to content

Instantly share code, notes, and snippets.

@bhb
Created June 23, 2017 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhb/6f06dd07bcf5b275a7d4faf3167bfc85 to your computer and use it in GitHub Desktop.
Save bhb/6f06dd07bcf5b275a7d4faf3167bfc85 to your computer and use it in GitHub Desktop.
A case where the `:in` value is not a path to the value
;;[org.clojure/clojure "1.9.0-alpha17"]
;;[org.clojure/clojurescript "1.9.542"]
;;[org.clojure/spec.alpha "0.1.123"]
(s/def :foo.user/name string?)
(s/def :foo/user (s/keys :req-un [:foo.user/name]))
(s/def :foo/user-map (s/map-of :foo.user/name :foo/user))
(s/explain-data :foo/user-map {"bob" {:age 2 :city "chicago"}})
;; returns the following...
(comment
#:cljs.spec.alpha{:problems
({:path [1],
:pred (contains? % :name),
:val {:age 2 :city "chicago"},
:via [:foo/user-map :foo/user],
:in ["bob" 1]})})
;; I would (perhaps mistakenly?) expect the `:in` value to be just ["bob"] since
;; (get-in {"bob" {:age 2 :city "chicago"}} ["bob"]) is {:age 2 :city "chicago"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment