It is set up outside any module, so it can't use DI; registering it with the
APP_PIPE token in a module allows injectionA pipe registered with useGlobalPipes() is created outside any module, so it can't use DI. Nest can't inject dependencies into it. To fix this, provide { provide: APP_PIPE, useClass: ValidationPipe } in a module. The pipe is then global and can use DI.
Why the other options are wrong:
• "The pipe can inject any provider through its constructor" is false, for the reason above.
• "It applies only to controllers in the root AppModule" is false. Global pipes apply to every route.
• "It runs before guards for every request" is false. Pipes always run after guards, and after the before-logic of interceptors.
Read more
- Pipes (https://docs.nestjs.com/pipes)docs.nestjs.com