import { ApiPropertyOptional } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { IsInt, IsOptional, IsString, Max, Min } from 'class-validator';

export class QuerySearchDto {
  @ApiPropertyOptional({
    example: 'tourism',
    description: 'What to look for. Shorter than 2 characters returns nothing.',
  })
  @IsOptional()
  @IsString()
  q?: string;

  @ApiPropertyOptional({
    example: 5,
    default: 5,
    maximum: 10,
    description: 'How many hits to return per group.',
  })
  @IsOptional()
  @Type(() => Number)
  @IsInt()
  @Min(1)
  @Max(10)
  limit?: number;
}
