-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ValidationPipe only works in Gateways if validateCustomDecorators=true #3127
Comments
I had a similar problem. Without digging too deep, I'd say it's the same. In my case it was introduced with In However, it's tried to be used at several points, e.g. in Consequently, This causes the |
Fixed in 6.8.3. Please, let me know if you face any issue. |
Awesome, 6.8.3 works (no validateCustomDecorators or MessageBody needed anymore). Thank you! |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Bug Report
Current behavior
Using below code I try to use the
ValidationPipe
to validate against myAuthenticateDto
class.@MessageBody
decorator, the transform-method ofValdiationPipe
is never called. Is that correct? It is not mentioned in the docs.@MessageBody
is used, I have to add{validateCustomDecorators: true}
to the pipe's options. Otherwise theValidationPipe
skips validation.Input Code
Expected behavior
It should not be neccessary to pass
validateCustomDecorators: true
to get validation working, because we also don't have to do it in HTTP controller context.Maybe it should also not be neccessary to use the
@MessageBody
decorator or the docs are wrong :)Possible Solution
Inside the
ValidationPipe
(here) it is checked whether the (data-)argument is of type"custom"
and if so whethervalidateCustomDecorators
is true. The question here should be: why is the type"custom"
and not, e.g.,"body"
? I used the@MessageBody
decorator, so it should be some kind of body/payload-type right?The
"custom"
-string is created here insideParamsTokenFactory
, based on thetype
-parameter passed in which is of typeRouteParamtypes
.Well, in this case, we use websockets, so the
type
-parameter is actually of typeWsParamtype
. Okay, but how could it get there?Check out this line of
PipesConsumer
. The type-castings allow any value to be passed there.To sum up,
WsContextCreator
uses thatPipesConsumer
which usesParamsTokenFactory
which, as described earlier, considers onlyRouteParamtypes
, notWsParamtype
to determine the type-string. Thus, for websockets the type is always"custom"
.This looks kinda wrong to me. Shouldn't the
PipesConsumer
work with different XyzTokenFactory's, depending on the context?ParamsTokenFactory
for HTTP and some newWsTokenFactory
for websockets?Environment
Maybe this issue is related: #3114
The text was updated successfully, but these errors were encountered: