import { ApiPropertyOptional } from '@nestjs/swagger';
import { IsArray, IsOptional, IsString } from 'class-validator';

/**
 * DTO used to add attachments to a specific entity.
 *
 * Supports multiple attachment files and categorizes them
 * by a type for organizational purposes.
 */
export class AddAttachmentDto {
  /**
   * Identifier of the entity to which attachments will be added.
   *
   * Required field:
   * - Must be a string.
   * - Could represent an ID of a record in a database.
   */
  @IsString()
  id: string;

  /**
   * Type or category of the attachment.
   *
   * Required field:
   * - Must be a string.
   * - Helps classify attachments (e.g., "invoice", "document", "receipt").
   */
  @IsString()
  type: string;

  /**
   * Optional array of attachment file names or URLs.
   *
   * Optional field:
   * - Each element must be a string.
   * - Allows multiple files to be associated with the entity.
   */
  @ApiPropertyOptional({ type: [String] })
  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  attachment_file?: string[];
}
