Hi, everyone is using spec/assert
in production a good practice ?
I want to produce detailed exceptions like spec/assert
does for mismatches
but do not want to allow some erroneous code to be able to disable the asserts by calling spec/check-asserts
.
Am I getting something wrong ?
Thanks a alot
I use spec/assert
in dev and custom function which is a mostly a valid?
+ throw
in production
Hi @vlaaad but this way I won't have descriptive exceptions like those thrown by spec/assert
. Am I right ?
@ho0man that's configurable by you. when I throw, I store spec/explain-data
as error data and use spec/explain-str
as error message — all the bits are there
Thanks a lot @vlaaad, I didn’t know about them Thanks
Curious if there's a way in spec to do the following:
{:a (s/coll-of int?)
:b (s/coll-of int? :count <3 times (count (:a this))>)}
or for that matter is it even possible to specify multiples instead of :count
in coll-of
?(need 3 coordinates per vertex ID, ideally, is what I'm going for)
@goomba Any predicate function is a spec, so you could use s/and
to combine a spec like you typed above (but without the bit about counts) with a predicate function checking that the counts are valid. If you want generation to work, you'll likely want to provide a custom generator that does something like generate a map with the proper types and then truncate things to make the counts work out.
ahhh okay thank you! I'll look into this.