This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-07-12
Channels
- # aleph (10)
- # beginners (79)
- # boot (81)
- # chestnut (3)
- # cider (9)
- # cljs-dev (336)
- # cljsrn (17)
- # clojure (121)
- # clojure-boston (1)
- # clojure-italy (4)
- # clojure-nl (1)
- # clojure-russia (218)
- # clojure-spec (32)
- # clojure-uk (98)
- # clojurescript (109)
- # cloverage (1)
- # core-async (5)
- # cursive (17)
- # datascript (15)
- # datomic (38)
- # editors (4)
- # emacs (6)
- # graphql (1)
- # hoplon (140)
- # instaparse (1)
- # jobs (2)
- # klipse (1)
- # leiningen (4)
- # lumo (2)
- # mount (103)
- # off-topic (3)
- # om (8)
- # onyx (19)
- # parinfer (32)
- # pedestal (3)
- # precept (32)
- # re-frame (33)
- # reagent (24)
- # remote-jobs (11)
- # rum (1)
- # spacemacs (1)
- # specter (37)
- # unrepl (4)
- # untangled (43)
- # vim (11)
I just realised that if you're using a tools.namespace based workflow, the spec registry isn't cleared when you refresh
. Is there a recommended way to "clean the registry" safely?
I suspect that if I just reset!
the registry I might be missing internal/clojure.core.specs specs?
(s/def ::eid (s/with-gen (s/and number?
pos?
#(instance? java.lang.Long %)
(complement nil?))
gen/int))
(s/fdef foo/bar
:args (s/cat :a any?
:b ::eid)
:ret (s/coll-of ::some/things))
what is es/eid
?
@twashing I can load this into a REPL fine:
(defn bar [])
(s/def ::eid (s/with-gen (s/and number?
pos?
#(instance? java.lang.Long %)
(complement nil?))
gen/int))
(s/fdef bar
:args (s/cat :a any?
:b ::eid)
)
how are you generating the error?::stuff
is a map with a fixed key :data
that will never change,.
(s/def :foo/data (s/keys :req [:relevant/key :another.relevant/key]))
(s/def ::stuff (s/keys :req-un [:foo/data]))
There is some how to "omit" :foo/data
definition?what’s the recommended way to run spec checks during automated testing? we’re currently using lein test with clojure.test and it would be nice to use something like the solution here https://stackoverflow.com/questions/40697841/howto-include-clojure-specd-functions-in-a-test-suite
if I have to I can copy & paste and adapt that code but it would be nice to have a supported library
@joost-diepenmaat if you paste it into https://github.com/gfredericks/schpec and make a PR, I'll release it not sure if that counts as "supported" or not
hi everyone! I'm trying to understand how to match :clojure.spec.alpha/problems inside :clojure.spec.alpha/value in explain-data result independent of the specs that were applied and I'm having some trouble
so the thing is that seeing a problem in [::k 1] you don't know if it means, it's the value of that key, or it's the element at pos 1 of a seq in the value of that key
does it make sense?
you're right in your analysis, it's been discussed before and it's logged in that ticket
great, thx a lot @bronsa
So I'm wondering, is spec with s/def
+ s/valid?
supposed to replace predicate functions? Otherwise I find it hard to decide what should be a spec and what should just be a function
Oh, I suppose that isn't really a good question. More pertinent would be whether new predicates should be written as anon functions in s/def
or should s/def
refer to a named predicate function
depends… sometimes the predicate function is generic and reusable but the s/def
can give it a more specific name/abstraction.
e.g.
(s/def ::user-id integer?)
(s/def ::post-id integer?)
othertimes the predicate is too specific to be reusable, so just keep it anonymous.
(No idea if this is best-practice btw… but it’s what I’ve been doing)
I am wondering how I would write a spec for a nested map. I have something like this {:1 {:user-id 1 :username "bob"} :2 {:user-id 2 :username "jim"}} Where I have a (s/def ::user (s/keys :req-un [::user-id ::username])). I know how to do this if I had a vector of users by using (s/coll-of ::user), but how would I approach this with having the map keys being the ::user-id spec and the values of each map being the ::user?