import { Type } from 'class-transformer';
import {
  IsDateString,
  IsIn,
  IsInt,
  IsOptional,
  IsString,
  Max,
  MaxLength,
  Min,
} from 'class-validator';
import {
  deletedRecordTypes,
  type DeletedRecordType,
} from './recycle-bin.registry';

export class RecycleBinQuery {
  @IsIn(['all', ...deletedRecordTypes])
  type: DeletedRecordType | 'all' = 'all';

  @IsOptional()
  @IsString()
  @MaxLength(200)
  search?: string;

  @IsOptional()
  @IsDateString()
  deletedFrom?: string;

  @IsOptional()
  @IsDateString()
  deletedTo?: string;

  @Type(() => Number)
  @IsInt()
  @Min(1)
  page = 1;

  @Type(() => Number)
  @IsInt()
  @Min(1)
  @Max(100)
  limit = 25;
}
