This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-08-05
Channels
- # bangalore-clj (1)
- # beginners (99)
- # boot (108)
- # cider (15)
- # clara (4)
- # cljs-dev (12)
- # cljsjs (37)
- # cljsrn (4)
- # clojure (110)
- # clojure-italy (2)
- # clojure-spec (12)
- # clojurescript (168)
- # cursive (1)
- # datomic (24)
- # graphql (6)
- # hoplon (5)
- # jobs-discuss (2)
- # keechma (21)
- # mount (5)
- # off-topic (140)
- # om (2)
- # parinfer (37)
- # planck (6)
- # re-frame (4)
- # reagent (9)
- # rum (2)
- # spacemacs (4)
@leongrapenthin I think you can do that, you have to give the fspec a name (make a s/def with it), use that name on your usages, then use spec overrides during the run of check, as documented here: https://github.com/clojure/spec.alpha/blob/master/src/main/clojure/clojure/spec/test/alpha.clj#L381
@wilkerlucio Not sure thats what I'm looking for. My case is like this: A global functions :args are speced like this (s/cat ::config (s/keys :req [::on-click-save])), then there is (s/def ::on-click-save (s/fspec :args (s/cat :cust ::customer)))
Now when I invoke the global function with {::on-click-save (fn [cust] (persist-on-server cust))}, on-click-save will be invoked a hundred times with generated ::customers by specs validation code
ah, true, that's for generators
well, not sure if there is an API for that, but something you could do is to change the spec registry directly, maybe that's a bad idea, but I guess it could work
Yeah sure
its just a map in an atom, nothing fancy
@wilkerlucio it appears that setting s/fspec-iterations is a workaround, but it disables it for all
setting it to 0
created a ticket for it https://dev.clojure.org/jira/browse/CLJ-2217
Anyone using spec to specify strings/routes/path/ns? I do not know if it was made for this, but it looks promising
(s/def ::path (s/or :path1 (s/cat :start #{\/}
:name (s/* (s/and char?
#(not= % \/))))
:path2 (s/cat :start #{\/}
:name1 (s/* (s/and char?
#(not= % \/)))
:div1 #{\/}
:name2 (s/* (s/and char?
#(not= % \/))))))
=> :user/path
(s/conform ::path (map identity "/foo"))
(s/conform ::path (map identity "/foo/bar"))
=> [:path1 {:start \/, :name [\f \o \o]}]
=> [:path2 {:start \/, :name1 [\f \o \o], :div1 \/, :name2 [\b \a \r]}]