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

ValidationPipe - forbidUnknownValues support #706

Closed
SebastianPodgajny opened this issue May 18, 2018 · 6 comments
Closed

ValidationPipe - forbidUnknownValues support #706

SebastianPodgajny opened this issue May 18, 2018 · 6 comments

Comments

@SebastianPodgajny
Copy link

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

ValidationPipe doesn't support forbidUnknownValues options property

Expected behavior

It should support it

Minimal reproduction of the problem with instructions

@UsePipes(new ValidationPipe({forbidUnknownValues: true}))

What is the motivation / use case for changing the behavior?

It is important validation mechanism also this option will be set to true in 1.0 class-validator release

Environment


Nest version: 5.0.0

 
For Tooling issues:
- Node version: 9.11.1  
- Platform: Linux Debian Buster 

Others:

@kamilmysliwiec
Copy link
Member

kamilmysliwiec commented May 19, 2018

Actually, it is supported (https://docs.nestjs.com/pipes)

@SebastianPodgajny
Copy link
Author

I couldn't get it working, but it might be related to some 'class-validator' bug. Anyway i think we need to include it in https://github.com/nestjs/nest/blob/master/packages/common/interfaces/external/validator-options.interface.ts

@kiwikern
Copy link
Contributor

This worked for me: new ValidationPipe({whitelist: true, forbidNonWhitelisted: true})

@kamilmysliwiec
Copy link
Member

Ahh, got it. forbidNonWhitelisted is missing in the ValidatorOptions interface. I'll fix it soon.

@kamilmysliwiec kamilmysliwiec added this to the 5.0.1 milestone May 23, 2018
@kamilmysliwiec kamilmysliwiec self-assigned this May 23, 2018
@kamilmysliwiec
Copy link
Member

Fixed in v5.0.1. Leaving opened to remember about the docs

@lock
Copy link

lock bot commented Sep 24, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants