diff --git a/src/main.ts b/src/main.ts index 9661e69..34aba4b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -6,7 +6,13 @@ async function bootstrap() { const app = await NestFactory.create(AppModule); // Global validation pipe - app.useGlobalPipes(new ValidationPipe()); + app.useGlobalPipes( + new ValidationPipe({ + whitelist: true, + forbidNonWhitelisted: true, + transform: true, + }), + ); // Global prefix app.setGlobalPrefix('api'); diff --git a/src/users/dto/update-user.dto.ts b/src/users/dto/update-user.dto.ts index cb09441..357b929 100644 --- a/src/users/dto/update-user.dto.ts +++ b/src/users/dto/update-user.dto.ts @@ -1,11 +1,4 @@ -import { - IsEnum, - IsOptional, - IsString, - Length, - Matches, -} from 'class-validator'; -import { UserRole } from '../enums/user-role.enum'; +import { IsOptional, IsString, Length } from 'class-validator'; export class UpdateUserDto { @IsOptional() @@ -17,12 +10,4 @@ export class UpdateUserDto { @IsString() @Length(1, 100) lastName?: string; - - @IsOptional() - @Matches(/^09\d{9}$/) - mobile?: string; - - @IsOptional() - @IsEnum(UserRole) - role?: UserRole; } diff --git a/src/users/users.service.ts b/src/users/users.service.ts index 17ca5fa..dbe4908 100644 --- a/src/users/users.service.ts +++ b/src/users/users.service.ts @@ -36,9 +36,6 @@ export class UsersService { async update(id: string, updateUserDto: UpdateUserDto): Promise { const user = await this.findOne(id); - if (updateUserDto.mobile) { - await this.ensureMobileIsUnique(updateUserDto.mobile, id); - } Object.assign(user, updateUserDto); return this.usersRepository.save(user); }