This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-01-10
Channels
- # adventofcode (3)
- # aws (2)
- # beginners (85)
- # boot (8)
- # boot-dev (4)
- # cider (36)
- # clara (3)
- # cljs-dev (87)
- # cljsrn (3)
- # clojure (87)
- # clojure-austin (12)
- # clojure-brasil (1)
- # clojure-dev (8)
- # clojure-dusseldorf (5)
- # clojure-estonia (5)
- # clojure-greece (4)
- # clojure-italy (3)
- # clojure-spec (17)
- # clojure-uk (55)
- # clojurescript (70)
- # core-logic (2)
- # cursive (6)
- # data-science (18)
- # datomic (13)
- # emacs (34)
- # fulcro (347)
- # graphql (12)
- # hoplon (6)
- # jobs (3)
- # jobs-discuss (43)
- # juxt (2)
- # keechma (31)
- # leiningen (29)
- # lumo (2)
- # midje (2)
- # off-topic (118)
- # om-next (4)
- # onyx (39)
- # pedestal (6)
- # re-frame (85)
- # reagent (21)
- # remote-jobs (3)
- # ring (5)
- # rum (2)
- # shadow-cljs (126)
- # spacemacs (1)
- # sql (6)
Would it be considered ok to promote s/assert* to good for "public" use (atm the docstring says : "Do not call this directly, use 'assert'.")
in cases where you want the check to always happen no matter the value of check-assert/compile-asserts
or is there a better way? ping @alexmiller
I seem to remember that I could generate with a provided example. Something like (gen/fill-in ::spec {::id "all generated will have this id, other values are generated"})
Can't remember what it was called though... anyone?
(s/def ::id string?)
(s/def ::foo (s/keys :req [::id]))
(s/exercise ::foo 2 {::id #(s/gen #{"a" "b"})})
;=>
;([{::id "a"} {::id "a"}]
; [{::id "b"} {::id "b"}])
?@misha yes, thank you!
(defn gen
"... Optionally an overrides map can be provided which
should map spec names or paths (vectors of keywords) to no-arg
generator-creating fns. These will be used instead of the generators at those
names/paths. Note that parent generator (in the spec or overrides
map) will supersede those of any subtrees.
parent generator will supersede those of any subtrees
part just bit me in the ass I have some function
(defn foo
[a]
{:pre [(s/valid? ::bar a)]}
...)
That asserts if the input conforms to a spec. It works well, but I’m having trouble to debug when it fails, I want to know what input I’m passing that doesnt conform and why.@pablore I use s/explain-data
instead of s/valid
. it returns nil
if everything is ok, and a datastructure, if there are any errors.
read through this too, may be it'll give you some ideas https://clojure.org/guides/spec#_using_spec_for_validation
afaik, specs are replacement of :pre
/`:post`-conditions