This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-09-17
Channels
- # 100-days-of-code (4)
- # announcements (4)
- # aws (2)
- # beginners (88)
- # cider (1)
- # cljsrn (9)
- # clojure (126)
- # clojure-conj (4)
- # clojure-dev (8)
- # clojure-greece (1)
- # clojure-italy (37)
- # clojure-nl (3)
- # clojure-spec (13)
- # clojure-uk (91)
- # clojurescript (392)
- # clojurewerkz (1)
- # clojutre (10)
- # core-async (6)
- # cursive (5)
- # data-science (1)
- # datomic (41)
- # emacs (21)
- # events (1)
- # figwheel-main (52)
- # fulcro (2)
- # hyperfiddle (4)
- # jobs (3)
- # jobs-discuss (9)
- # luminus (3)
- # lumo (9)
- # mount (1)
- # nyc (1)
- # off-topic (73)
- # other-languages (6)
- # pedestal (8)
- # portkey (2)
- # re-frame (9)
- # reagent (8)
- # rum (17)
- # shadow-cljs (38)
- # sql (19)
- # tools-deps (18)
- # yada (4)
is anyone aware of a way to strictly validate some data against a spec? e.g. fail on extraneous map keys, etc.
here's one way https://github.com/gfredericks/schpec/blob/master/src/com/gfredericks/schpec.clj#L13
and I think spec-tools has another way, although the general advice is to not make map/keys specs "closed"
If you just want to guard against typos, check out https://github.com/bhauman/spell-spec
in this case it’s closed, though, and the user can make all kinds of interesting typlos
@U0HM5MJ5V you also could do (s/and (s/keys ...) (s/map-of #{<allowed-keys-only>} any?))
to see whether this behavior is actually what you need. saves you custom macro or dependency.
@U051HUZLD great, thanks! didn’t realize map-of
was strict