Files
negareh-api/src/modules/product/dto/create-food.dto.ts
T
2026-01-07 12:24:55 +03:30

123 lines
2.3 KiB
TypeScript

import { Type } from 'class-transformer';
import {
ArrayUnique,
IsArray,
IsBoolean,
IsEnum,
IsInt,
IsNotEmpty,
IsNumber,
IsOptional,
IsString,
Max,
Min,
} from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { MealType } from '../interface/product.interface';
export class CreateproductDto {
@IsNotEmpty()
@IsString()
@ApiProperty()
categoryId: string;
@IsOptional()
@IsString()
@ApiPropertyOptional({ example: 'قرمه سبزی' })
title?: string;
@IsOptional()
@IsString()
@ApiPropertyOptional({ example: 'توضیحات غذا' })
desc?: string;
@IsOptional()
@IsArray()
@IsString({ each: true })
@ApiPropertyOptional({ type: [String] })
content?: string[];
@IsOptional()
@IsArray()
@ArrayUnique()
@IsInt({ each: true })
@Min(0, { each: true })
@Max(6, { each: true })
@Type(() => Number)
@ApiPropertyOptional({ type: [Number], example: [0, 1, 2, 3, 4, 5, 6] })
weekDays?: number[];
@IsOptional()
@IsArray()
@ArrayUnique()
@IsEnum(MealType, { each: true })
@ApiPropertyOptional({ enum: MealType, isArray: true })
mealTypes?: MealType[];
@IsOptional()
@IsNumber()
@Min(0)
@Type(() => Number)
@ApiPropertyOptional({ example: 120000 })
price?: number;
@IsOptional()
@IsInt()
@Min(0)
@Type(() => Number)
@ApiPropertyOptional({ example: 15 })
prepareTime?: number;
@IsOptional()
@IsBoolean()
@ApiPropertyOptional({ example: true })
@Type(() => Boolean)
isActive?: boolean;
@IsOptional()
@IsArray()
@IsString({ each: true })
@ApiPropertyOptional({ type: [String] })
images?: string[];
@IsOptional()
@IsBoolean()
@ApiPropertyOptional({ example: false })
@Type(() => Boolean)
inPlaceServe?: boolean;
@IsOptional()
@IsBoolean()
@ApiPropertyOptional({ example: false })
@Type(() => Boolean)
pickupServe?: boolean;
@IsOptional()
@IsNumber()
@Min(0)
@Type(() => Number)
@ApiPropertyOptional({ example: 0 })
discount?: number;
@IsOptional()
@IsNumber()
@Min(0)
@Type(() => Number)
@ApiProperty({ example: 50 })
dailyStock: number;
@IsOptional()
@IsBoolean()
@ApiPropertyOptional({ example: false })
@Type(() => Boolean)
isSpecialOffer?: boolean;
@IsOptional()
@IsInt()
@Min(0)
@Type(() => Number)
@ApiPropertyOptional({ example: 1 })
order?: number;
}