25 lines
650 B
TypeScript
25 lines
650 B
TypeScript
import { IsNotEmpty, IsNumber, IsOptional, IsString, Max, Min } from 'class-validator';
|
|
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
import { Type } from 'class-transformer';
|
|
|
|
export class CreateFoodCommentDto {
|
|
@IsNotEmpty()
|
|
@IsString()
|
|
@ApiProperty({ description: 'Food ID' })
|
|
foodId: string;
|
|
|
|
@IsNotEmpty()
|
|
@IsNumber()
|
|
@Min(1)
|
|
@Max(5)
|
|
@Type(() => Number)
|
|
@ApiProperty({ description: 'Rating from 1 to 5', example: 5, minimum: 1, maximum: 5 })
|
|
rating: number;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
@ApiPropertyOptional({ description: 'Comment text', example: 'Very delicious food!' })
|
|
comment?: string;
|
|
}
|
|
|