#Access to Execution context inside pipe
11 messages · Page 1 of 1 (latest)
The ExecutionContext does not get passed to pipes, so it's not possible to use the Reflector easily. Is this so you can bind a global pipe but still use schemas for validation, like with Zod?
actually, I am using Joi. I've implemented a solution for this but it's not global (I created a decorator that gets schema and fires UsePipes decorator and passes validation schema into new JoiValidationPipe(schema). but I want to make it clean up and productive, so I found the metadata solution that, as you said, is impossible! Is it not possible to pass execution context into pipes? I mean, in the next version of Nest, or has it fundamental blockers?
I have a schema based pipe (zod, but the idea extends to joi and arktypes) that works based on class metadata. I can point youto my custom solution if you want to see it
Reflection metadata wouldn't (easily) help anyways, because you can use multiple @Body()/@Query()/@Param()/etc in a method so you'd have to reflect the schema in a way the pipe can properly handle it
Yes please, it can be useful to see your idea
It's similar to my validation pipe. Thanks for sharing that
do you have any documentation for metadata and reflector that nest used?
Thanks very much 🙏
@halcyon geyser btw soon that reflector API will be more type-safe: https://github.com/nestjs/nest/pull/12237
PR Checklist
Please check if your PR fulfills the following requirements:
The commit message follows our guidelines: https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md
Tests for the chan...