We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
https://docs.nestjs.com/techniques/validation#stripping-properties http://static.kancloud.cn/juukee/nestjs/2675355 https://juejin.cn/post/7064595876680826910
app.useGlobalPipes( new ValidationPipe({ transform: true, }), );
@Get(':id') findOne(@Param('id') id: number) { console.log(typeof id === 'number'); // true return 'This action returns a user'; }
id 会自动从 string 转换成 number
app.useGlobalPipes( new ValidationPipe({ whitelist: true, }), );
true 时,自动删除非白名单属性(在验证类中没有任何修饰符的属性)。
// Bad // 所有参数都将被过滤 export class CreateCatDto { public name: string; public age: number; public breed: string; } // Good import { IsNumber, IsString } from 'class-validator'; export class CreateCatDto { @IsString() public name: string; @IsNumber() public age: number; @IsString() public breed: string; }
"typeorm": "^0.3.6", "typeorm": "0.2.45",
0.3.x 按照文档无法工作 0.2.x 按照文档正常工作
The text was updated successfully, but these errors were encountered:
No branches or pull requests
class-validator
ValidationPipe
transform
id 会自动从 string 转换成 number
whitelist
true 时,自动删除非白名单属性(在验证类中没有任何修饰符的属性)。
typeorm
0.3.x 按照文档无法工作
0.2.x 按照文档正常工作
The text was updated successfully, but these errors were encountered: