validate-reql
allows validation of rethinkdb reql queries using a whitelist of reql validators. this was specifically designed to work w/ rethinkdb-primus.
Installation
npm i --save rethinkdb-validator
Usage
Validate ReQL using a whitelist of exact ReQL queries.
Example: test if reql is in reql whitelist
var validateReql = var r = var reql = r var whitelist = r // Failure Casesvar reql1 = r
Validate ReQL using custom validation
rethinkdb-validator monkey patches rethinkdb w/ some new methods
r.rvRef
and rvValidate
Example: Custom validation using refs: // Place r.rvRef('<name>')
in place of ReQL you want to manually validate in your whitelist ReQL
// Note: if the actual value from the ReQL is a sequence of ReQL you will have to test it as Rethink AST
var validateReql = var r = var reql = r var whitelist = r // Failure Casesvar whitelist2 = r
Example: Custom validation using property tests
// Place r.rvTest(func)
in place of ReQL you want to manually validate inline in your whitelist ReQL
var validateReql = var r = var reql = r var whitelist = r
Credits
Thank you Mike Mintz! Code is heavily inspired by rethinkdb-websocket-server
License
MIT