UNPKG

pl4y-data-library

Version:

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

39 lines (30 loc) 871 B
import { IsEnum, IsNumber, IsOptional, IsString, IsDate, Max, Min, IsNotEmpty } from "class-validator"; import { Type } from "class-transformer"; import { CurrencyCodeEnum } from "../../../enums/currency-code.enum"; export class PricingDTO { @IsOptional() id?: string; @IsString() @IsNotEmpty() productId: string; @IsNumber() price: number; @IsEnum(CurrencyCodeEnum, { message: "Invalid currency code" }) currencyCode: CurrencyCodeEnum; @IsOptional() @IsString() supplierId?: string; @IsOptional() @Type(() => Date) @IsDate() effectiveDate?: Date; @IsOptional() @Type(() => Date) @IsDate() expiryDate?: Date; @IsOptional() @IsNumber() @Min(0, { message: "Discount must be at least 0%" }) @Max(100, { message: "Discount cannot exceed 100%" }) discount?: number; }