Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import {ValidationPipe} from "@nestjs/common";
- const myPipe = new ValidationPipe({
- transform: true,
- whitelist: true
- });
- // In app bootstrap (global for the entire app)
- app.useGlobalPipes(myPipe);
- // In your module (global for that module)
- import {APP_PIPE} from "@nestjs/core";
- import {Module} from "@nestjs/common";
- // ...
- providers: [
- {
- provide: APP_PIPE,
- useFactory: function () {
- return myPipe
- }
- }
- ]
- // ...
- // In your controllers (specific for that controller)
- @UsePipes(myPipe)
- @Controller()
- export class MyFooController {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement