Is there a way to ensure that nestjs dto optional properties do not have null values?
@ApiProperty({
type: String,
format: 'string',
})
@IsOptional()
@IsString()
readonly name?: string;
One potential solution is:
@ApiProperty({
type: String,
format: 'string',
required: false, // This will make it optional for the docs
})
@ValidateIf((o) => o.name !== undefined)
@IsString()
readonly name?: string;
I wish there was something like: @IsNotNull