This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-01-23
Channels
- # aleph (1)
- # architecture (4)
- # aws (7)
- # beginners (249)
- # boot (17)
- # calva (4)
- # cider (30)
- # cljdoc (7)
- # cljs-dev (1)
- # cljs-experience (3)
- # clojure (69)
- # clojure-dev (7)
- # clojure-europe (1)
- # clojure-italy (7)
- # clojure-japan (15)
- # clojure-spec (6)
- # clojure-uk (39)
- # clojurescript (51)
- # cursive (31)
- # data-science (4)
- # datavis (1)
- # datomic (40)
- # dirac (67)
- # duct (8)
- # editors (15)
- # emacs (9)
- # events (3)
- # figwheel-main (2)
- # fulcro (157)
- # juxt (4)
- # kaocha (11)
- # lein-figwheel (1)
- # off-topic (31)
- # pathom (18)
- # re-frame (4)
- # reagent (2)
- # reitit (16)
- # remote-jobs (1)
- # shadow-cljs (11)
- # specter (2)
- # speculative (1)
- # tools-deps (27)
- # vim (1)
- # yada (2)
Hm, I'm a bit confused about the s/or
. Trying to get spec to accept that a key can be either a-map
or b-map
, both of them are fine, so far got this:
(s/def :test/a-map (s/keys :req-un [::name]))
(s/def :test/b-map (s/keys :req-un [::title]))
(s/def :test/key (s/or :test/a-map :test/b-map))
(s/def :test/map (s/keys :req-un [:test/key]))
(comment
(s/valid? :test/map {}) ;; false
(s/valid? :test/map {:key {:name "hello"}}) ;; false / should be true
(s/valid? :test/map {:key {:title "hello"}}) ;; true
)
you need to label it with a keyword, e.g.
(s/def :test/key (s/or :a :test/a-map :b :test/b-map))
ugh, should have been obvious if I just read the docs slower, missed the key+pred pairs. I'll blame it on too little coffee
I had the same once, no worries
It doesn't blow up either so hard to know you did something wrong (without coffee 😉 )
☕ 5