Fork me on GitHub
#clojure-spec
<
2020-11-18
>
Dmytro Bunin15:11:29

I stumbled upon this behavior, which I found a bit weird.

(s/def :sequence-list/eid number?)
(s/valid?
 (s/keys :opt []) ;; ⇠ no reference to :sequence-list/eid
 (merge #:entity {:label "foo"}
        #:sequence-list {:eid "sample"}))
=> false
does the s/keys look at global registry in some way?

alexmiller15:11:58

s/keys will check all registered keys in the map

alexmiller15:11:21

so even (s/keys) is a spec that does things

Dmytro Bunin15:11:05

interesting, thanks 🙂

alexmiller15:11:46

this is covered if you (doc s/keys) or look at the spec guide https://clojure.org/guides/spec

Dmytro Bunin15:11:48

> > 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.

Dmytro Bunin15:11:58

yeah says so in docstring 🙂