import { ArrayMinSize, IsArray, IsDateString, IsInt, IsOptional, IsPositive, IsString, Matches, MinLength, ValidateIf, } from 'class-validator'; import { Type } from 'class-transformer'; export class UpdateBusinessDto { @IsOptional() @IsString() @MinLength(2) nameFa?: string; @IsOptional() @IsString() @MinLength(2) name?: string; @IsOptional() @IsString() about?: string; @IsOptional() @IsString() @Matches(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, { message: 'slug must be lowercase letters, numbers, and hyphens', }) slug?: string; @IsOptional() @IsArray() @ArrayMinSize(1) @Type(() => Number) @IsInt({ each: true }) categoryIds?: number[]; @IsOptional() @ValidateIf((_, value) => value !== null) @Type(() => Number) @IsInt() ownerUserId?: number | null; /** Legacy WillaEngine businesses.id; null clears the link. */ @IsOptional() @ValidateIf((_, value) => value !== null) @Type(() => Number) @IsInt() @IsPositive() oldBusinessId?: number | null; @IsOptional() @ValidateIf((_, value) => value !== null) @IsDateString() annualRenewalAt?: string | null; /** * Business SMS shortcode for customer messages (e.g. 5000123456). * Empty string or null clears it (falls back to Meshkee advertising number). */ @IsOptional() @ValidateIf((_, value) => value !== null && value !== '') @IsString() @Matches(/^\d{8,16}$/, { message: 'smsSenderNumber must be an 8–16 digit shortcode', }) smsSenderNumber?: string | null; }