In my create DTO, I defined an optional parameter with a default value. However, when using the update DTO, even though I didn't pass that parameter, it still appeared in the controller. How can I prevent this from happening?
import { IsOptional } from 'class-validator';
export class CreateAdminDto {
readonly username: string;
@IsOptional()
readonly firstName?: string | null = 'admin';
}
import { PartialType } from '@nestjs/mapped-types';
import { CreateAdminDto } from './create-admin.dto';
export class UpdateAdminDto extends PartialType(CreateAdminDto) {}