Fork me on GitHub
#clojure-spec
<
2016-11-05
>
bbloom00:11:44

finally getting around to trying spec in anger

bbloom00:11:55

is there a standard conform-or-throw function?

hiredman01:11:40

there is a/assert, but you need to set a property to turn it on

richiardiandrea01:11:41

@bbloom I so wanted that too, unconditionally, I could not find it and copied over s/assert and named it valid-or-throw 😄

richiardiandrea01:11:13

great I'll tweet you 😉

dominicm12:11:51

Is there yet a way to "scope" an error done against a whole map? Given that I have:

{:x 1
 :y [2 3 4 5]}
And want to validate that :x must be contained in :y, but I want my error message to state that it is :x that is wrong, not the whole map. How would I do it?

Alex Miller (Clojure team)13:11:46

s/and a function that checks that x is in y?

Alex Miller (Clojure team)13:11:33

The error should list that function

Alex Miller (Clojure team)13:11:53

As the failing predicate

dominicm14:11:12

@alexmiller I'm thinking more of the :path of the error (I think that's the key)

tianshu15:11:32

how can i turn on the :ret check for clojure.spec/fdef.

mpenet19:11:10

I had deal with that pb recently, If you check on test.check wiki there's a page explaining how to deal with recursive gen and how to limit gen depth/size

mpenet19:11:00

(I am on my phone, not easy to find)

bbloom22:11:16

is there a spec somewhere for the ns form or “libspec” data?

gfredericks23:11:00

@bbloom I think you can poke around to find how the spec for ns is implemented

gfredericks23:11:11

(doc ns) might even help with that

bbloom23:11:46

duuuuh i forget that core had all the specs in there now

gfredericks23:11:52

(clojure.spec/form :clojure.core.specs/ns-clauses)

gfredericks23:11:00

and clojure.spec/form

bbloom23:11:08

anyway - i decided to do my own spec for a tiny subset of the complexity of the full ns form

bbloom23:11:18

pretty narrow use case