This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-11-17
Channels
- # bangalore-clj (4)
- # beginners (60)
- # boot (63)
- # cider (2)
- # cljs-dev (22)
- # cljsrn (3)
- # clojars (32)
- # clojure (133)
- # clojure-gamedev (1)
- # clojure-germany (17)
- # clojure-italy (1)
- # clojure-russia (11)
- # clojure-serbia (16)
- # clojure-spec (35)
- # clojure-uk (75)
- # clojurebridge (1)
- # clojurescript (83)
- # community-development (25)
- # core-async (43)
- # cursive (15)
- # datomic (28)
- # emacs (2)
- # fulcro (108)
- # graphql (5)
- # hoplon (15)
- # lein-figwheel (6)
- # leiningen (39)
- # lumo (106)
- # new-channels (1)
- # off-topic (4)
- # om (26)
- # om-next (53)
- # onyx (46)
- # other-languages (2)
- # perun (1)
- # protorepl (5)
- # re-frame (13)
- # ring (18)
- # ring-swagger (1)
- # rum (6)
- # shadow-cljs (82)
- # spacemacs (19)
- # specter (5)
- # sql (3)
- # test-check (31)
- # unrepl (12)
- # untangled (2)
- # vim (109)
when writing the :fn bit of an fdef, doesn anyone have any tips or examples to figure out which bit of the fn failed if there are multiple properties that should hold?
or
with labels almost gives what I want, but obviously isn't logically correct. I want something like all
something abit like:
(s/all [{{:keys [first]} :args second :ret}]
:value-mismatch #(= (:value first)
(:value second)))
would be very tidy for checking a value was copied correctly in the functionis there a way to write a spec that says: a collection containing two or more integers and anything else?
would became something like, and it would need to be a collection, and when filtered on number? the size is minimal of 2
Does anyone know if you can spec a map and have it conformed into multiple parts depending on the key. For example, conform {:A 1 :B 2 :a 1 :b 2}
into something like {:upper {:A 1 :B2} :lower {...}}
. Basically a group-by during a conform.
I essentially want different rules for different kinds of keys in a map. So certain styles of keys would have different value requirements.
From what I've been seeing of the usage of spec, I'd guess not. Seems like it falls under the "data transformation" camp which is not something they intend spec to be used for.
but I might be wrong
Yep, that's how I was beginning to feel about it. I'm currently doing that transformation after the fact, but it's hard to find them in a recursive spec, so I can't do the transform up front ahead of time.
I would quite like different specs for different kinds of keys though, not sure if I can do that.
In my case, if it starts with on-
I want it to be restricted to a function value. If it's anything else it should be a string.
makes sense. Does it have to be a tree? You could {:upper/A 1 :upper/B 2 :lower/a 1...}
and not quite sure what you mean by "different specs for different kinds of keys though, not sure if I can do that."
Yup, I'm not sure either 🙂 It's like, I don't care about the actual keys, as long as they're keywords. But if it starts with on-
it should be a function. I wonder if I can combine map-of
and keys
. It's almost like I want two stages, conform as much as you can with this spec, THEN conform with this spec.
I just need constraints between key and value. Otherwise if I exercised this spec it would generate invalid runtime data, but it would match the spec.
Yeah, for what you're saying it seems like map-of
would be a fitting choice
But I'm not sure if there's a way to treat the key/value pair as a whole with map-of
Another option might be coll-of
if map-of
doesn't work, since that way you could probably spec each entry as [k v]
pairs
For context, this is an attribute map that will be applied to DOM nodes in this little Reagent/React like thing I'm building.
So most keys will just be strings that go to setAttribute on a DOM node, but event listeners are special things that are handled separately.
Aaaaand bingo https://stackoverflow.com/questions/38151446/how-can-i-spec-a-hybrid-map
nice one!
which is really just me bumping this: https://clojurians.slack.com/archives/C1B1BB2Q3/p1510906494000281