import { ApiPropertyOptional } from '@nestjs/swagger';
import { IsDateString, IsOptional, IsString } from 'class-validator';
import { PaginationDto } from 'src/config/pagination/paginationDto';

/**
 * DTO (Data Transfer Object) for searching release notes
 * Extends PaginationDto to include pagination parameters (page, per_page, etc.)
 * This DTO is used for validating and documenting API query parameters
 */
export class SearchReleaseNotesDto extends PaginationDto {
  /**
   * Optional filter for release version
   * Supports partial matching in the service layer
   *
   * @example "ERP001"
   * @example "ERP"
   */
  @ApiPropertyOptional({
    description: 'Filter release notes by version (supports partial matching)',
    example: 'ERP001',
    required: false,
  })
  @IsOptional() // Field is not required
  @IsString() // Must be a string if provided
  release_version?: string;

  /**
   * Optional filter for release date
   * Expected in ISO 8601 date format (YYYY-MM-DD)
   * Used for exact date matching in the service layer
   *
   * @example "2024-01-15"
   */
  @ApiPropertyOptional({
    description: 'Filter release notes by specific release date',
    example: '2024-01-15',
    required: false,
  })
  @IsOptional() // Field is not required
  @IsDateString() // Must be a valid ISO 8601 date string if provided
  release_date?: Date;
}
