UNPKG

pl4y-data-library

Version:

This library contains the dtos, enums, schemas, and other data objects needed in the pl4y ecosystem.

65 lines (51 loc) 1.26 kB
import { IsEnum, IsNotEmpty, IsOptional, IsString, IsBoolean, IsNumber, Min, IsInt } from "class-validator"; import { ProductCategory } from "../../../enums/product-categories.enum"; import { ProductUOM } from "../../../enums/product-uom.enum"; export class ProductDTO { @IsOptional() id?: string; @IsString() @IsNotEmpty() name: string; @IsString() @IsNotEmpty() brand: string; @IsInt() @IsEnum(ProductCategory, { message: "Invalid category" }) category: ProductCategory; /** * Properties worked on by a restriction service */ @IsOptional() @IsString() regulationType?: string; @IsOptional() @IsNumber() @Min(0) minimumAge?: number; @IsOptional() @IsBoolean() requiresVerification?: boolean; /** * Properties worked on by a restriction service */ @IsOptional() @IsBoolean() isWeighable?: boolean; @IsNumber() @Min(0) quantity: number; @IsOptional() @IsNumber() @Min(0) weight?: number; @IsInt() @IsEnum(ProductUOM, { message: "Invalid unit of measurement" }) uom: ProductUOM; @IsString() @IsNotEmpty() upc: string; @IsString() @IsNotEmpty() sku: string; }