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

Accept only keys defined in rule object #448

Open
bytemerger opened this issue Mar 11, 2022 · 1 comment
Open

Accept only keys defined in rule object #448

bytemerger opened this issue Mar 11, 2022 · 1 comment

Comments

@bytemerger
Copy link

bytemerger commented Mar 11, 2022

I am using the version 3.22.1

Could it be possible to have a feature where the validator can return an error if data key with that is not defined in the rule is passed
for instance

const validator = new Validator(req.body, {
        name: 'string',
        body: 'string',
    });

The above should return an error if req.body contains more object keys than defined in the rule

A solution could be to add a third instance parameter to new Validator(data,rule,strict)
strict would either be true or false.
This would mean whether the validator should follow the rule strictly not allowing additional keys or not.

@eyan
Copy link

eyan commented Apr 5, 2022

+1 for this feature request!

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

No branches or pull requests

2 participants