apa512 / clj-rethinkdb

Eclipse Public License 1.0
204 stars 42 forks source link

Use clojure.spec for query validation and shaping #168

Open danielcompton opened 8 years ago

danielcompton commented 8 years ago

Clojure.spec could be really useful for clj-rethinkdb. Currently we have some functions with ambiguous arities and we need to do adhoc runtime type checking to resolve it. In other cases we just haven't attempted some arities when they could be useful. specing functions would (I think?) allow us to get around this, and provide a more structured way for handling functions with the same arity but different possible behaviours.

Query validation would also be possible. This could be very loose, e.g. making sure the types for each argument are correct, or much more rich, i.e. enforcing that an insert call has been called with a table.

Things to look at:

spec is very new, so we probably wouldn't be merging anything based on this until Clojure released it officially.