import { IsString, IsOptional, IsNotEmpty, IsEmail, MaxLength, IsArray, ArrayMaxSize, ValidateNested, IsIn } from 'class-validator'; import { Transform, Type } from 'class-transformer'; import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; export class ImportPlannedTabEntryDto { @ApiProperty({ example: 'Jan Peeters' }) @IsString() @IsNotEmpty() @MaxLength(100) customerName: string; @ApiPropertyOptional({ example: 'jan@example.com' }) @IsOptional() @Transform(({ value }) => (typeof value === 'string' ? value.trim() || undefined : value)) @IsEmail() email?: string; } export class ImportPlannedTabsDto { @ApiProperty({ type: [ImportPlannedTabEntryDto] }) @IsArray() @ArrayMaxSize(5000) @ValidateNested({ each: true }) @Type(() => ImportPlannedTabEntryDto) entries: ImportPlannedTabEntryDto[]; @ApiProperty({ enum: ['merge', 'replace'], description: 'merge adds new names and updates emails; replace also removes names that are not in the import', }) @IsIn(['merge', 'replace']) mode: 'merge' | 'replace'; }