This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-07-05
Channels
- # announcements (1)
- # asami (21)
- # aws (19)
- # babashka (37)
- # beginners (38)
- # clj-kondo (7)
- # clj-otel (8)
- # clojure (29)
- # clojure-europe (54)
- # clojure-nl (3)
- # clojure-spec (2)
- # clojure-uk (2)
- # clojurescript (15)
- # conjure (1)
- # data-science (1)
- # datomic (21)
- # emacs (6)
- # events (3)
- # figwheel-main (1)
- # gratitude (13)
- # holy-lambda (11)
- # joyride (6)
- # klipse (3)
- # malli (14)
- # missionary (26)
- # nbb (31)
- # omni-trace (2)
- # pathom (3)
- # reagent (1)
- # reitit (1)
- # releases (1)
- # shadow-cljs (24)
- # sql (27)
- # tools-deps (4)
- # vim (21)
I have a map which needs to have at least one of three possible keys. Sometimes one of those keys is present but with an empty map. I want to not count that as fulfilling the requirement in the or
in :test/map
but also not invalidate the entire map if one of the other two keys is present and valid. Any way of doing that without first dissoc'ing those keys with empty values?
(s/def :test/b ;; c and d look similar
(s/and not-empty
(s/map-of number? (s/multi-spec mm :test/type))))
(s/def :test/map
(s/keys :req [:test/a
(or :test/b
:test/c
:test/d)]
:opt [:test/e
:test/f]))
with spec, your only option would be a conformer that manipulates the map ahead of the spec. or you can s/and an arbitrary predicate that does anything you want.
👍 1