你好。我想与useGlobalPipes一起使用ValidationPipe globaly。我使用:
<Card title="Card Name" className="hightlight">
<Input placeholder="Your Input" />
</Card>
但这不起作用。仅当我在控制器中添加VAlidationPipe时才能工作:
import 'dotenv/config';
import {NestFactory} from '@nestjs/core';
import {ValidationPipe} from '@nestjs/common';
import {AppModule} from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.useGlobalPipes(new ValidationPipe({
transform: true,
whitelist: true,
}));
await app.listen(3000);
}
bootstrap();