Closed antyale closed 1 year ago
This is behaving as expected. Your DTO only defines page
and limit
so the third query parameter status
is unknown to the dto. As @Query()
is essentially req.query
and nest doesn't pull any values off of it, the entire over is passed for validation.
Is there an existing issue for this?
Current behavior
I have a global validation pipe that uses
forbidNonWhitelisted
so it throws an exception for invalid parameters:It seems that this is causing some issues when using DTO classes and multiple @Query params in the controller endpoint. For example, the following code should take
status
as a valid query param, but instead it throws{"statusCode":400,"message":["property status should not exist"],"error":"Bad Request"}
Setting
forbidNonWhitelisted
to false avoids the exception and the endpoint takes thestatus
query param correctly.Thanks!
Minimum reproduction code
https://stackblitz.com/edit/nestjs-typescript-starter-mv5eul
Steps to reproduce
npm install && npm start
on the StackBlitz project?status=pending
query param to the running app urlExpected behavior
The ValidationPipe should not throw an exception.
Package
Other package
No response
NestJS version
^9.4.0
Packages versions
Node.js version
18.12
In which operating systems have you tested?
Other
No response