import { ApiProperty } from '@nestjs/swagger';
import { IsArray, IsNotEmpty, IsNumber } from 'class-validator';

/**
 * DTO for searching courses offered by a college campus.
 *
 * This DTO is used to filter and fetch courses for a specific institute
 * across selected campuses and study levels. It ensures that all required
 * fields are provided and in the correct format.
 */
export class SearchCollegeCampusCoursesDto {
  /**
   * The ID of the institute for which courses are being searched.
   *
   * Validation rules:
   * - Must not be empty
   * - Must be a number
   *
   * Example payload:
   * ```json
   * {
   *   "institute_id": 123
   * }
   * ```
   */
  @ApiProperty({
    description: 'ID of the institute',
    example: 123,
  })
  @IsNotEmpty({ message: 'institute_id is required' })
  @IsNumber({}, { message: 'institute_id must be a number' })
  institute_id: number;

  /**
   * Array of campus IDs within the institute.
   *
   * Validation rules:
   * - Must not be empty
   * - Must be an array
   * - Each element is expected to be a number
   *
   * Example payload:
   * ```json
   * {
   *   "campuses": [1, 2, 3]
   * }
   * ```
   */
  @ApiProperty({
    description: 'Array of campus IDs to filter courses',
    type: [Number],
    example: [1, 2, 3],
  })
  @IsNotEmpty({ message: 'campuses array cannot be empty' })
  @IsArray({ message: 'campuses must be an array of numbers' })
  campuses: number[];

  /**
   * Array of study level IDs for filtering courses.
   *
   * Validation rules:
   * - Must not be empty
   * - Must be an array
   * - Each element is expected to be a number
   *
   * Example payload:
   * ```json
   * {
   *   "study_levels": [101, 102]
   * }
   * ```
   */
  @ApiProperty({
    description: 'Array of study level IDs to filter courses',
    type: [Number],
    example: [101, 102],
  })
  @IsNotEmpty({ message: 'study_levels array cannot be empty' })
  @IsArray({ message: 'study_levels must be an array of numbers' })
  study_levels: number[];
}
