@monirul017@avantar
I had exactly same problem and after investigating it is happening because of {whitelist: true} of ValidationPipe and when you set it to false it will working properly but I didn't continue in this way because I want to whitelist the properties so temporary I added _requestContext to the related DTO file that I used in my controller and added it as an @IsOptional() decorator
import { REQUEST_CONTEXT } from '../../../interceptors/inject-request-param.interceptor';
@IsOptional()
\[REQUEST_CONTEXT\]: any;
Ignore "\" from the above code.
For others trying to use this article as a solution continue using from attached repository.
this is not working ValidationArguments does not hold REQUEST_CONTEXT
Are you sure you created interceptor, which injects the REQUEST_CONTEXT? I'm using similar code in my production-ready app and it works for me.
yes i am using but its not working btw.I did exactly the way you said
even console logged the args but REQUEST_CONTEXT returns undefined
@monirul017 @avantar
I had exactly same problem and after investigating it is happening because of
{whitelist: true}
of ValidationPipe and when you set it to false it will working properly but I didn't continue in this way because I want to whitelist the properties so temporary I added_requestContext
to the related DTO file that I used in my controller and added it as an @IsOptional() decoratorIgnore "\" from the above code.
For others trying to use this article as a solution continue using from attached repository.
At the end thank you @avantar for your solution.
Thank you, @siavash_habil! This can be helpful as well.
github.com/AvantaR/nestjs-validati...
@avantar This is almost happened at the same time for both of us because I solved it about 20 hours ago. :)
Thank you for sharing.
What a coincidence! Magic 🎉
There was obviously typo in decorator composition class. Instead of
AddUseTo
, there should beInjectUserTo
. Please try if it works for you now.