clojure-spec

About: http://clojure.org/about/spec Guide: http://clojure.org/guides/spec API: https://clojure.github.io/spec.alpha/clojure.spec.alpha-api.html
2021-04-11T20:01:07.018900Z

I'm trying to spec a large, complicated map for a bunch of game data. there are several possible states the game might be in, and the fields vary depending on which state we're in. I want a spec something like (s/def ::state-pregame (s/merge ::state-core (s/keys pregame-specific-things) {::state :states/pregame}))

2021-04-11T20:01:22.019300Z

where the key is that last bit, specifying a particular key and value pair for the pregame state.

2021-04-11T20:08:05.019600Z

oh, TIL about multi-spec, which is exactly this.