Skip to content
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

Validate Keys passed as body/query paramters? #558

Closed
yousufmj opened this issue Apr 4, 2018 · 2 comments
Closed

Validate Keys passed as body/query paramters? #558

yousufmj opened this issue Apr 4, 2018 · 2 comments
Milestone

Comments

@yousufmj
Copy link

yousufmj commented Apr 4, 2018

Hi, Is there a way to validate the keys used in requests? we can validate the values that are passed in but i want to ensure only certain keys are used. similar to issue #266

eg post request could be
/user/create
{ "name": "john", "answer": "yes", "notValid": "Im not a valid key" }

is there a way to either use schema or check to ensure only certain keys are used;
possible schema example;
checkSchema({ name: { in: 'param', optional: true }, answer: { in: 'param', optional: true } )

if any other parameters that are not stated in the schema to throw an error to say not valid options. similar to how jsonschema module works

@gustavohenke
Copy link
Member

So, as mentioned in the original issue, nowadays we have wildcards (unlike at the time of opening of that issue), which make this feature a lot more complicated to implement.

Imagine a selector like foo.*.bar; it would need to find all siblings of foo and bar, and reject them; so { foo: [{ bar: 1, baz: 2 }], qux: true } would reject foo[0].baz and qux.

It certainly is possible, just is very complex to solve properly.

@gustavohenke
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants