Fork me on GitHub
#clojure-spec
<
2018-03-07
>
gfredericks00:03:03

that was my guess

Andreas Liljeqvist15:03:07

is there any function like (complete ::somespec {::provided-value 2}) that will generate keys that aren't provided?

Andreas Liljeqvist15:03:57

I could provide overrides like {::provided-value #(gen/return 2)}

Andreas Liljeqvist16:03:18

I have written such a function, just interested to know if it exists somewhere in spec

jimbob17:03:19

is there any way to have fdef functions be runtime validated?

jimbob17:03:37

Or are these function specs only for documentation / testing and generation

taylor17:03:48

you can instrument the functions to check the :args specs

taylor17:03:24

and there’s another lib called Orchestra that gives you a version of instrument that checks :args and :ret (and maybe :fn?)

jimbob17:03:41

brilliant. exactly what i was looking for, thanks a lot @taylor!

aengelberg21:03:53

Is this a bug?

user=> (s/def ::a integer?)
:user/a
user=> (s/explain (s/merge (s/keys :req [::a]) (s/keys :req [::b])) {::a "a" ::b 1})
In: [:user/a] val: "a" fails spec: :user/a at: [:user/a] predicate: integer?
In: [:user/a] val: "a" fails spec: :user/a at: [:user/a] predicate: integer?
nil

aengelberg22:03:18

I would expect only one message to get spit out, not two. But since s/merge calls each of its sub-maps' validators, it gets the error message twice.

misha22:03:45

@aengelberg each s/keys validates keys for presence, and every key of a known spec (even not mentioned ones) for conformance

misha22:03:10

(s/def ::a integer?)
(s/def ::m (s/keys :req [::b]))
(s/explain ::m {::a "a"})
In: [:user/a] val: "a" fails spec: :user/a at: [:user/a] predicate: integer?
val: #:user{:a "a"} fails spec: :user/m predicate: (contains? % :user/b)
=> nil

misha22:03:13

and s/merge does not reduce issues from each subspec