-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Query validation of array data #15
Comments
Also, related, but I'm not sure how to validate queries of the form:
For example, comparing the id's in the getAll against a valid list. |
For your first query, you're right that its not working because the const MAKE_ARRAY = 2;
const checkArr = checkFn => term => (
Array.isArray(term)
&& term.length === 2
&& term[0] === MAKE_ARRAY
&& Array.isArray(term[1])
&& checkFn(term[1])
);
// whitelist entry
r.table('test').insert(
checkArr(arr => arr.every(e => e.id > 0))
) But this should ideally be addressed at the library level. I think it'll probably be safest to make something like |
I don't think there's an easy way to do validate variable number of arguments like |
Great, thanks! This helps a lot for now. Regarding variable number of arguments, I'm thinking a workaround for now is to pass an array wrapped in |
Great idea using r.table('test').getAll(
r.args(checkArr(arr => arr.every(e => e.id > 0)))
) Assuming the rethinkdb backend supports |
What's the best way to validate a query like this? For example, to ensure id > 0
Whitelisting like this fails, I think because arr is a parsed query as opposed to a js array. I'm not sure how to loop through it.
The text was updated successfully, but these errors were encountered: