the partialType in not working for my updateDto it not making option my nested object variable in update dto. the main thing is that its only not working for boolean values mean not doing option boolean type in updateDto here is createDto
class PoolDTO {
@IsBoolean()
present: boolean;
@IsOptional()
@IsString()
fence: string;
@IsOptional()
@IsString({ each: true })
location: string;
}
class UtilitiesDTO {
@IsBoolean()
sprinklerSystem: boolean;
@IsBoolean()
sumpPump: boolean;
@IsBoolean()
sumpPit: boolean;
@ValidateNested()
@Type(() => PoolDTO)
pool: PoolDTO;
@IsBoolean()
spaHot: boolean;
@IsBoolean()
water: boolean;
@IsBoolean()
gas: boolean;
@IsBoolean()
electric: boolean;
@IsOptional()
@IsString()
comment: string;
}
export class CreateDto{
@IsString()
@IsNotEmpty()
number: string;
@ValidateNested()
@Type(() => PoolDTO)
pool: PoolDTO;
@ValidateNested({ each: true })
@Type(() => UtilitiesDTO)
utilities: UtilitiesDTO;
and here is update dto
import { PartialType } from '@nestjs/mapped-types';
import { CreateDto } from './create.dto';
export class UpdateDto extends PartialType(CreateDto) {}
it gives me validation error
"messages": [
"utilities.sprinklerSystem must be a boolean value",
"utilities.sumpPump must be a boolean value",
"utilities.sumpPit must be a boolean value",
"utilities.water must be a boolean value",
"utilities.gas must be a boolean value",
"utilities.electric must be a boolean value"
]
but i'm used PartialType which is The PartialType() function returns a type (class) with all the properties of the input type set to optional. still i'm getting error i'm not want to write updatedto want to used same createdto for updatedto
The
PartialType()function is imported from the@nestjs/swaggerpackage.