import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { ArrayMaxSize, ArrayMinSize, IsArray, IsOptional, IsUUID, Matches, ValidateIf } from 'class-validator';

export class ProgramarPagosDto {
  @ApiProperty({ type: [String], description: 'Cuotas (cuentas_pagar.id) a programar' })
  @IsArray()
  @ArrayMinSize(1)
  @ArrayMaxSize(500)
  @IsUUID('all', { each: true })
  cuenta_pagar_ids: string[];

  @ApiPropertyOptional({ nullable: true, description: 'Día de pago (YYYY-MM-DD). null = quitar la programación' })
  @IsOptional()
  @ValidateIf((_, v) => v !== null)
  @Matches(/^\d{4}-\d{2}-\d{2}$/, { message: 'fecha debe ser YYYY-MM-DD' })
  fecha?: string | null;
}
