This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-12-29
Channels
- # announcements (7)
- # babashka (36)
- # beginners (67)
- # braveandtrue (11)
- # cider (8)
- # clojure (52)
- # clojure-conj (4)
- # clojure-poland (1)
- # clojure-spec (9)
- # clojure-uk (8)
- # clojurescript (42)
- # core-typed (11)
- # cursive (4)
- # emacs (1)
- # fulcro (1)
- # graalvm (24)
- # hoplon (10)
- # hyperfiddle (1)
- # off-topic (30)
- # re-frame (7)
- # reitit (1)
- # sql (1)
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
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.