/**
 * FetchByUsersDto
 * ----------------
 * DTO used to fetch Menu Groups based on user association.
 *
 * Purpose:
 * - Determines whether to fetch records by `created_by` or `updated_by`
 * - Ensures only allowed enum values are accepted
 *
 * Used in:
 * - MenuGroupsController.getCreatedByOrUpdatedByUsers()
 *
 * Example Payload:
 * {
 *   "by": "created"
 * }
 */
import { IsIn, IsNotEmpty } from 'class-validator';
import { ByUserType } from 'src/utils/enums/enum';
import { ApiProperty } from '@nestjs/swagger';

export class FetchByUsersDto {
  /**
   * User Association Type
   * ---------------------
   * Defines which user relationship should be used for filtering.
   *
   * Possible Values (ByUserType enum):
   * - created   → Fetch records created by users
   * - updated   → Fetch records last updated by users
   *
   * Validation:
   * - Required field
   * - Value must match one of the enum values
   *
   * Why @IsIn(Object.values(ByUserType))?
   * - Ensures runtime validation against enum values
   * - Prevents invalid strings from passing validation
   *
   * Swagger:
   * - Enum dropdown automatically generated in Swagger UI
   */
  @ApiProperty({ enum: ByUserType })
  @IsNotEmpty()
  @IsIn(Object.values(ByUserType))
  by: ByUserType;
}
