class-transformer remove property in @Type() if exists

Viewed 87

I have User entity with three fields:

export class UserEntity {
  public id: number;
  public uuid: string;
  public email: string;
}

Also I have update-user.dto.ts file:

export class UpdateUserDto {
  @IsUUID()
  public uuid: string;

  @Type(() => UserEntity)
  public dataToUpdate: Partial<UserEntity>;
}

My question is, is it possible to cut 'id' property off from 'dataToUpdate' property or fail validation if 'id' property is existed inside ''dataToUpdate'?

0 Answers
Related