This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-12-10
Channels
- # adventofcode (174)
- # announcements (5)
- # aws (9)
- # babashka (17)
- # beginners (259)
- # boot-dev (1)
- # calva (6)
- # cider (19)
- # circleci (7)
- # clj-kondo (9)
- # cljfx (51)
- # cljs-dev (4)
- # clojure (83)
- # clojure-australia (2)
- # clojure-dev (9)
- # clojure-europe (78)
- # clojure-nl (3)
- # clojure-spec (4)
- # clojure-switzerland (1)
- # clojure-uk (18)
- # clojurescript (22)
- # conjure (17)
- # cursive (17)
- # data-science (1)
- # datomic (15)
- # defnpodcast (1)
- # events (2)
- # fulcro (39)
- # graalvm (16)
- # graphql (1)
- # kaocha (5)
- # lambdaisland (11)
- # malli (6)
- # meander (1)
- # off-topic (26)
- # pathom (10)
- # re-frame (10)
- # reitit (6)
- # rewrite-clj (7)
- # sci (3)
- # shadow-cljs (28)
- # sql (12)
- # test-check (10)
- # tools-deps (31)
Hi, I'm trying to figure out how to implement xor for a map keys. Where I'd like to check if one of the keys is present but not both at the same time.
(s/def ::a int?)
(s/def ::b int?)
(s/def ::c string?)
Where following maps are invalid:
{::c "string"} ;; missing ::a
xor ::b
{::a 1 ::b 2 ::c "string"} ;; both ::a
and ::b present
and the following maps are valid:
{::a 1 ::c "string"}
{::b 2 ::c "string"}s/keys
only supports regular or
: https://stackoverflow.com/a/41901585
but you could combine the s/keys
spec with a custom xor
spec via s/and
, as described in https://stackoverflow.com/a/43374087
Thank you. My searching on duck duck go didn't return this answer from SO. That's what I was looking for.
In the docs for s/keys
I saw that or
is supported but not xor