Thanks for the tip here. abstract-map-schema works really well. One thing that I would add to it if I could would be a dispatch function rather than just keywords, but I don't need that at the moment.
On Sunday, 6 March 2016 18:41:53 UTC-8, Jason Wolfe wrote: > > If I'm understanding correctly, this sounds like a > `schema.experimental.abstract-map-schema` to me (it's basically shorthand > for what Bobby suggests) . There's an example in the readme. > > Best, Jason > > On Sunday, March 6, 2016 at 5:28:31 AM UTC+5:30, JvJ wrote: >> >> I've been using Schema, and there's a kind of type definition that I'm >> having trouble with. I'm not sure exactly how to describe it, so I'll >> provide an example. >> >> I'm working on a digital card game in which there are numerous zones that >> a card may be in. Each card needs to know which zone it is in, and there >> may be additional information depending on the zone. >> >> For instance, if a card is in a player's hand, no additional information >> is required. However, if the card is on the board, it needs to understand >> its position on the board. >> >> I have the following definition for zone types: >> >> (def Zone >> "A schema for referring to the various game zones." >> (s/enum :Hand >> :Deck >> :Board >> :Field >> :Discard >> :Void)) >> >> I want to define a different schema type for each of these, and then >> define a zone spec: >> >> (def ZoneSpec {(required-key :zone-type) Zone >> :data <zone data corresponding to the zone type >> specified earlier> >> }) >> >> I want to ensure that whichever data is provided specified the schema >> associated with the zone type. >> >> Is there a way to do this? >> >> Thanks. >> > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.