#Access to Execution context inside pipe

11 messages · Page 1 of 1 (latest)

halcyon geyser
#

I wanna use metadata above of my controller methods, to pass schema validation to global custom validation pipe. but I didn't access to execution context to put it inside reflector.get() method.

pallid bramble
#

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?

halcyon geyser
#

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?

pallid bramble
#

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

halcyon geyser
halcyon geyser
halcyon geyser
#

Thanks very much 🙏

zenith meteor