On Friday, June 17, 2016 at 2:46:37 PM UTC-5, Brian Platz wrote: > > > I'd like to be able to use clojure.spec for input validation where the > specs are stored in a database using a data structure to represent them. >
Why don't you represent them as code loaded by different applications? s/form is designed to give you a wire-portable definition of a spec. > s/keys and its requirement to use the registry makes this challenging. > > I'm able to generate specs dynamically using a workaround like: > (eval (cons 's/and <predicates>)) > > However, I don't see a way of utilizing s/keys in this manner, as the > keys must first be placed in the registry. > > I could register each key also using eval and s/def similarly to my > example above, however that would eliminate this method's use in a > multi-tenant environment where one client/instance may have a different > spec than another. > > The following ideas could make this much simpler: > - Allow s/keys to accept a spec to use with each key (i.e. the same > format used by s/or). > The independence of attribute specs is a fundamental tenet of spec and this will not be changed. > - Allow a *spec-registry* binding, enabling the use of multiple registries > The notion of multiple registries is something that's been raised, but Rich will have to be the one to comment on that. > > Any other ideas or anything I've missed that would make this use case more > feasible? > There might be a function version of s/keys in the future that can take a vector of keys. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
