import { IsIn, IsInt, IsNotEmpty } from 'class-validator';
import { Type } from 'class-transformer';
import { AssociationType, ByUserType } from 'src/utils/enums/enum';
import { ApiProperty } from '@nestjs/swagger';

/**
 * DTO used to fetch records based on user reference type.
 *
 * This is typically used to determine whether data should be
 * fetched by `created_by`, `updated_by`, or similar user-based
 * associations.
 */
export class FetchByUsersDto {
  /**
   * User reference type.
   *
   * Must be one of the allowed values defined
   * in the ByUserType enum.
   *
   * Example:
   * - CREATED_BY
   * - UPDATED_BY
   */
  @ApiProperty({ enum: ByUserType })
  @IsNotEmpty() // Ensures the field is present in the request
  @IsIn(Object.values(ByUserType)) // Restricts value to valid enum options
  by: ByUserType;
}
