Hi i have nest app dto:
export class TestDto {
@IsNotEmpty()
id: number;
@IsNotEmpty()
slug: string;
@IsNotEmpty()
size: number;
}
and Post request:
@Post(':id/start')
async startTest(
@Param('id') id: number,
@Request() req,
@Body() testDto?: TestDto
): Promise<RoomDto | string> {
return await this.roomsService.startTest(id, testDto);
}
I want to have testDto from body optional but instead i have an error when sending request:
{
"statusCode": 400,
"message": [
"slug should not be empty",
"size should not be empty"
],
"error": "Bad Request"
}
How to achieve something like this?