This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-02-02
Channels
- # aws-lambda (1)
- # beginners (46)
- # boot (190)
- # cider (12)
- # clara (6)
- # cljs-dev (9)
- # cljsjs (8)
- # clojure (152)
- # clojure-austin (3)
- # clojure-berlin (3)
- # clojure-finland (2)
- # clojure-france (5)
- # clojure-italy (3)
- # clojure-russia (92)
- # clojure-serbia (4)
- # clojure-spec (7)
- # clojure-uk (190)
- # clojurescript (115)
- # cursive (20)
- # datomic (20)
- # dirac (4)
- # emacs (9)
- # gsoc (5)
- # hoplon (1)
- # jobs (1)
- # klipse (4)
- # lein-figwheel (1)
- # leiningen (6)
- # lumo (2)
- # mount (18)
- # off-topic (57)
- # om (68)
- # om-next (14)
- # onyx (33)
- # perun (32)
- # portland-or (4)
- # re-frame (21)
- # reagent (85)
- # ring (6)
- # ring-swagger (23)
- # schema (1)
- # uncomplicate (1)
- # untangled (13)
- # vim (7)
Hi, I am wondering if maybe I have stumbled across an issue in clojure.spec
. I have perused the issue list but have found nothing that I think describes the issue at hand for me.
A small example:
(s/def :some.ns.1/k string?)
(s/def :some.ns.1/m (s/keys :req [:some.ns.1/k]))
(s/def :some.ns.2/k string?)
(s/def :some.ns.2/m (s/keys :req-un [:some.ns.2/k]))
(s/explain-str :some.ns.2/m {:k "1"
:some.ns.1/m {}})
;; => "In: [:some.ns.1/m] val: {} fails spec: :some.ns.1/m at: [:some.ns.1/m] predicate: (contains? % :some.ns.1/k)\n"
My point being, although I am checking (doesn't matter if I use s/explain-str
, s/assert
etc) for :some.ns.2/m
- clojure.spec ends up also validating another spec.
That is, although :some.ns.1/m
is in there and not conforming to spec - I did not expect it to be checked for. I also noticed that this happens both when I use :req-un
and :req
for :some.ns.2/m
Hmm, no seems I am mistaken, I found this in the spec source docs for clojure.spec/keys
:
> In addition, the values of all namespace-qualified keys will be validated
> (and possibly destructured) by any registered specs. Note: there is
> no support for inline value specification, by design.
How have I not stumbled across this before?