import { IsArray, IsBoolean, IsEnum, IsNotEmpty, IsNumber, IsString, IsUUID, MaxLength, Min } from 'class-validator'; import { getAppConfig } from '../../../config'; import { NullOrDate, NullOrInt, NullOrNumber } from '../../../validation/decorators/nullOr'; import { DiscountType } from '../types/DiscountType'; const { validation: { discountCodeMaxLength } } = getAppConfig(); export class CreateOrUpdateDiscountCodeDto { @IsNotEmpty() @IsString() @MaxLength(discountCodeMaxLength) code: string; @IsNotEmpty() @IsEnum(DiscountType) type: DiscountType; @IsNotEmpty() @IsNumber() @Min(0) value: number; @IsNotEmpty() @IsBoolean() isActive: boolean; @NullOrDate() validFrom: Date | null; @NullOrDate() validUntil: Date | null; @NullOrInt({ min: 1 }) maxRedemptions: number | null; @NullOrNumber({ min: 0 }) minOrderAmount: number | null; @IsNotEmpty() @IsBoolean() isExclusive: boolean; @IsArray() @IsUUID('4', { each: true }) productIds: string[]; @IsArray() @IsUUID('4', { each: true }) categoryIds: string[]; @IsArray() @IsUUID('4', { each: true }) variantIds: string[]; }