import { ArrayMinSize, IsArray, IsIn, IsISO8601, IsNumber, IsOptional, IsString, MaxLength, Min, MinLength, ValidateIf, ValidateNested, } from 'class-validator'; import { Type } from 'class-transformer'; import { BUSINESS_FIELDS } from '@mento/shared'; import type { UpdatePriorArchiveCutoffRequest } from '@mento/shared'; export class ExchangeRateInputDto { @IsString() @MinLength(3) @MaxLength(8) currency!: string; @Type(() => Number) @IsNumber() @Min(0.000001) rateToBase!: number; } export class UpdateOrgCurrenciesDto { @IsOptional() @IsString() @MinLength(3) @MaxLength(8) baseCurrency?: string; @IsOptional() @IsArray() @ArrayMinSize(1) @IsString({ each: true }) enabledCurrencies?: string[]; @IsOptional() @IsArray() @ValidateNested({ each: true }) @Type(() => ExchangeRateInputDto) rates?: ExchangeRateInputDto[]; } export class CreateOrganizationDto { @IsString() @MinLength(2) @MaxLength(120) name!: string; @IsOptional() @IsIn([...BUSINESS_FIELDS]) businessField?: (typeof BUSINESS_FIELDS)[number]; } export class UpdateOrganizationDto { @IsOptional() @IsString() @MinLength(2) @MaxLength(120) name?: string; @IsOptional() @IsIn([...BUSINESS_FIELDS]) businessField?: (typeof BUSINESS_FIELDS)[number]; } export class UpdatePriorArchiveCutoffDto implements UpdatePriorArchiveCutoffRequest { /** بدون دکوراتور، whitelist پایپ Nest فیلد را حذف می‌کرد و ذخیره همیشه خطا می‌داد. */ @ValidateIf((_, value) => value !== null) @IsISO8601() cutoffAt!: string | null; }