Fork me on GitHub
#clojure-spec
<
2018-09-17
>
spieden19:09:19

is anyone aware of a way to strictly validate some data against a spec? e.g. fail on extraneous map keys, etc.

taylor19:09:37

and I think spec-tools has another way, although the general advice is to not make map/keys specs "closed"

bbrinck21:09:01

If you just want to guard against typos, check out https://github.com/bhauman/spell-spec

bbrinck21:09:16

but yes, the general advice is not to make specs closed

spieden22:09:47

yes generally i leave them open

spieden22:09:40

in this case it’s closed, though, and the user can make all kinds of interesting typlos

bbrinck22:09:25

Yep, I think spell-spec is a good fit then

misha06:09:29

@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.

spieden16:09:30

@U051HUZLD great, thanks! didn’t realize map-of was strict

misha17:09:05

well, #{} is strict, but yeah

spieden19:09:59

ah of course