This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-01-02
Channels
- # beginners (29)
- # boot (65)
- # cider (12)
- # cljs-dev (8)
- # cljsjs (31)
- # clojars (5)
- # clojure (147)
- # clojure-austin (47)
- # clojure-berlin (1)
- # clojure-brasil (7)
- # clojure-russia (5)
- # clojure-spec (18)
- # clojure-uk (18)
- # clojurescript (113)
- # css (2)
- # cursive (7)
- # datascript (5)
- # datomic (2)
- # dirac (4)
- # events (3)
- # funcool (143)
- # hoplon (287)
- # jobs (2)
- # off-topic (4)
- # om (10)
- # om-next (5)
- # onyx (18)
- # protorepl (1)
- # re-frame (93)
- # reagent (34)
- # rum (41)
- # test-check (51)
- # untangled (15)
- # yada (18)
I have these specs :
; specs for validatimg input to find rhe ids
(s/def ::artObject (s/keys :req-un [::objectNumber]))
(s/def ::artObjects (s/coll-of ::artObject))
(s/def ::body (s/keys :req-un [::artObjects]))
(s/def ::response (s/keys :req-un [::body]))
Can I just make a copy with it and extend it and named all the keywords then ::data-response
so I'm working on my idea of writing a defn
-like macro that infers specs from the (extended) destructuring syntax of the argument vector
and I was thinking that in the case of a simple case of {:keys [(foo int?)]}
, which of course means that the passed map contains an optional unqualified key of :foo
which is an int
I need to define the spec for :foo
. would it be a terrible idea to just use a randomly generated ns for that such as :foo1235/foo
?
i.e. the argument vector [{:keys [(foo int?)]}]
expands to (s/def :foo1235/foo int?)
+ (s/cat :m (s/keys :opt-un [:foo1235/foo]))
I don't want to end up in a situation where my defn-macro ends up overwriting specs for situations where multiple functions accept maps that contain simple-keywords that can contain different types of values
@roelof It is hard to tell what exactly you want to do. At least for me. I am pretty sure you can do what you want, but if you need help I guess you need to be more specific and provide some examples.
Also, it seems to be the same question you’ve asked several times now — and it has been answered in the #beginners channel...
I have answered it at least twice now in the #beginners channel and you’ve had input from other people there.
I'm doing my best to understand spec. I'm working through a cards example, using my own representation of a card. I've defined my specs as follows:
According to the spec spec, my definition for cards should be checking for correct conformance for ::suit and ::rank. But (s/conform ::card "1m") returns "1m", not an invalid as I expect. What's happening here?
@luxbock I'd use the current ns plus an extra random segment as the namespace
@fadrian suits
should be a set, not a map.
(line 1)