import { IsDateString, IsIn, IsNumber, IsOptional, IsString, MaxLength, Min, ValidateIf } from 'class-validator';

export class UpdateDiscountDto {
    @IsOptional()
    @IsIn(['amount', 'percentage'])
    discountType?: 'amount' | 'percentage';

    @IsOptional()
    @IsNumber()
    @Min(0.01)
    discountValue?: number;

    @IsOptional()
    @IsString()
    @MaxLength(500)
    discountReason?: string;

    @IsOptional()
    @ValidateIf((o) => o.discountValidUntil !== null)
    @IsDateString()
    discountValidUntil?: string | null;
}
