This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-10-24
Channels
- # aleph (1)
- # babashka (2)
- # beginners (25)
- # calva (5)
- # cider (8)
- # cljdoc (4)
- # clojure (81)
- # clojure-europe (41)
- # clojure-spec (11)
- # clojurescript (7)
- # conjure (1)
- # data-science (1)
- # datomic (25)
- # defnpodcast (3)
- # events (2)
- # figwheel-main (8)
- # fulcro (5)
- # helix (4)
- # hugsql (1)
- # java (2)
- # off-topic (35)
- # onyx (18)
- # pathom (8)
- # rdf (5)
- # re-frame (9)
- # reagent (3)
- # reitit (1)
- # shadow-cljs (39)
- # tools-deps (53)
- # xtdb (23)
hey, is there a way to reuse the same spec for different map keys without having to redefine them over and over?
(s/def ::address (some-pred-to-check-ethereum-addr))
(s/def ::tx (s/keys :req-un [:sender ::address ;; apply address spec to :sender
:recipient ::address])) ;; apply address spec to :recipient
@wcalderipe you can do this:
(def spec (s/....)
(s/def ::a spec)
(s/def ::b spec)
No, it won’t like that but you could set it quoted and make it work via s/register
But I don’t think that works the way it’s requested with req-un in either case
thanks @alexmiller and @borkdude
Yes, but will still have repetition
s/keys
is the best way to check the shape of a map?