Fork me on GitHub
#clojure-spec
<
2019-02-02
>
drone01:02:55

running into issues with circular references between specs (::a references ::b in it’s definition and vice versa). taking a step back to consider alternative ways to model the specs, but will spec2 support referring to undefined specs? As in:

(s/def ::a ::b)
(s/def ::b <spec>)

Alex Miller (Clojure team)03:02:25

Yes, and I have done some more work there to defer lookups more pervasively

👍 5
kenny02:02:14

I'd be nice to use s/assert in production but if you s/assert a spec that contains a fspec, it will require test.check to check the value. Is is possible to disable this functionality in production but still use the s/assert check?

seancorfield03:02:55

How would it check the spec then @kenny?

seancorfield03:02:44

(and you've got the same problem if you use s/valid? or s/conform, right?)

kenny03:02:24

fn? is all I need in prod.

kenny03:02:50

It’d be nice to get Spec error messages without the overhead of generation.

seancorfield03:02:27

(s/valid? fn? thing)

seancorfield03:02:19

If you want checks in production, put them in the code explicitly with s/valid? and/or s/conform.

seancorfield03:02:35

Asserts in production are a code smell, IMO, since they throw an Error, not an Exception so you're basically going to "kill" your request/process.

seancorfield03:02:04

If you want "Spec error messages" then you don't really want s/assert -- you want explicit code to check validity and call explain or something.

👍 5