Closed saroro1 closed 1 year ago
// user.enity.ts export class User { @PrimaryGeneratedColumn() id: number; @Column({ unique: true, length: 30 }) email: string; }
// update-user.ts export class UpdateUserDto extends PartialType(CreateUserDto) { /** * @format email */ email?: string; }
//user.controller.ts @TypedRoute.Post('/modify') async updateUser( @TypedBody() updateUser: UpdateUserDto, @Req() req: Request & Record<'user', JwtPayload>, ) { await this.userService.modifyUser(req.user.id, updateUser); }
When sending request with json body {"id" : "asdgsd", "email" : "john@gmail.com"}, It occurs error because nestia only checks whether body contains specific keys or not.
{"id" : "asdgsd", "email" : "john@gmail.com"}
Could you add strict mode to prevent from wrong body like upper case?
Good idea
Upgrade to @nestia/core@1.3.3, and configure "validate" property of plugin to be "assertEquals"
@nestia/core@1.3.3
When sending request with json body
{"id" : "asdgsd", "email" : "john@gmail.com"}
, It occurs error because nestia only checks whether body contains specific keys or not.Could you add strict mode to prevent from wrong body like upper case?