import { ApiProperty } from '@nestjs/swagger';
import { Transform } from 'class-transformer';
import { IsString, Length } from 'class-validator';

/** `GET /busqueda?q=`: el texto se recorta antes de validar (dos espacios no son una búsqueda). */
export class BusquedaQueryDto {
  @ApiProperty({ example: '001-001-0000123', minLength: 2, maxLength: 60 })
  @Transform(({ value }) => (typeof value === 'string' ? value.trim() : value))
  @IsString({ message: 'La búsqueda tiene que ser un texto' })
  @Length(2, 60, { message: 'La búsqueda tiene que tener entre 2 y 60 caracteres' })
  q!: string;
}
