Fork me on GitHub
#clojure-spec
<
2016-11-13
>
wei11:11:45

what do I need to do to get fdef to throw errors on invalid return values?

(defn x [] "hello")
(s/fdef x :ret number?)

=> (x)
"hello"

yonatanel11:11:18

Also, is there a way to require a bunch of same-namespaced keys without specifying the namespace on each one?

yonatanel14:11:14

Is there a best practice for conformers, like one that can transform a string to java.util.UUID - should I call it ::uuid, ->uuid etc?

Alex Miller (Clojure team)14:11:20

@wei not supported. ret and fn specs are checking that a function works, which is seen as a testing time activity supported only by stest/check

Alex Miller (Clojure team)14:11:42

@yonatanel: re multimethods, certainly no opposition to it, but needs some work

Alex Miller (Clojure team)14:11:31

@yonatanel: re ns keys, use create-ns to create the namespace, then alias to alias it. There is a pending patch to remove the first step.

Alex Miller (Clojure team)14:11:49

Re conformers, no convention

wei18:11:46

@alexmiller what would you recommend for checking inputs at runtime using spec? s/valid? inside of a :pre?

madstap18:11:45

@yonatanel There's a version of alias in https://github.com/gfredericks/schpec that creates the namespace, then aliases to it.

wei18:11:42

nevermind, figured it out, the guide does mention :pre/:post

wei18:11:17

what are some tradeoffs between s/check-asserts and :pre/post?

Alex Miller (Clojure team)18:11:47

Check-asserts can be turned on and off or even compiled out