Nest: ValidationPipe - forbidUnknownValues support

Created on 18 May 2018  路  6Comments  路  Source: nestjs/nest

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:

type question 馃檶

Most helpful comment

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

All 6 comments

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

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

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

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

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

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

VRspace4 picture VRspace4  路  3Comments

cojack picture cojack  路  3Comments

rlesniak picture rlesniak  路  3Comments

FranciZ picture FranciZ  路  3Comments

JulianBiermann picture JulianBiermann  路  3Comments