56 lines
812 B
TypeScript
56 lines
812 B
TypeScript
import {
|
|
IsArray,
|
|
IsInt,
|
|
IsNumber,
|
|
IsOptional,
|
|
IsString,
|
|
Min,
|
|
ValidateNested,
|
|
ArrayMinSize,
|
|
} from 'class-validator';
|
|
import { Type } from 'class-transformer';
|
|
|
|
class CreateRecipeIngredientDto {
|
|
@IsInt()
|
|
productId!: number;
|
|
|
|
@IsNumber()
|
|
@Min(0)
|
|
quantity!: number;
|
|
|
|
@IsString()
|
|
unit!: string;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
note?: string;
|
|
}
|
|
|
|
export class CreateRecipeDto {
|
|
@IsString()
|
|
name!: string;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
description?: string;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
instructions?: string;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
imageUrl?: string;
|
|
|
|
@IsOptional()
|
|
@IsInt()
|
|
@Min(1)
|
|
servings?: number;
|
|
|
|
@IsArray()
|
|
@ArrayMinSize(1)
|
|
@ValidateNested({ each: true })
|
|
@Type(() => CreateRecipeIngredientDto)
|
|
ingredients!: CreateRecipeIngredientDto[];
|
|
}
|