Cannot extend ValidationPipe
properly
#13143
Labels
needs triage
This issue has not been looked into
ValidationPipe
properly
#13143
Is there an existing issue for this?
Current behavior
I'm trying to extend
ValidationPipe
to create aCustomPipe
, but I've noticed that the injection of theCustomPipe
doesn't work properly.Specifically, even though there is no provider for the first parameter of
CustomPipe
, Nest ignores it. If the provider exists, the injection works fine.I believe this is because the
@Optional()
applied to the first parameter ofValidationPipe
is applied to the subclass (CustomPipe
) as well. This seems to happen because@Optional
stores the index of the parameter in the metadata.Minimum reproduction code
https://stackblitz.com/edit/nestjs-typescript-starter-ktzqni?file=src%2Fapp.module.ts,src%2FcustomPipe.ts
Steps to reproduce
npm install && npm start
Expected behavior
I think Nest should prevent
@Optional
from propagating to child classes so that the injection of child classes can be done correctly, because the same problem occurs when we try to extend any class that uses@Optional
, not justValidationPipe
.Package
@nestjs/common
@nestjs/core
@nestjs/microservices
@nestjs/platform-express
@nestjs/platform-fastify
@nestjs/platform-socket.io
@nestjs/platform-ws
@nestjs/testing
@nestjs/websockets
Other package
No response
NestJS version
10.2.6
Packages versions
Node.js version
18.18.0
In which operating systems have you tested?
Other
No response
The text was updated successfully, but these errors were encountered: