import { ApiProperty } from '@nestjs/swagger';
import { PropertyType } from '@prisma/client';
import { Transform } from 'class-transformer';
import { IsArray, IsEnum, IsString } from 'class-validator';

export class GetPriceTrendDto {
  @ApiProperty({ description: 'District name' })
  @IsString()
  district!: string;

  @ApiProperty({ description: 'City name' })
  @IsString()
  city!: string;

  @ApiProperty({ enum: PropertyType, description: 'Property type' })
  @IsEnum(PropertyType)
  propertyType!: PropertyType;

  @ApiProperty({ description: 'Comma-separated list of periods', type: [String] })
  @IsArray()
  @IsString({ each: true })
  @Transform(({ value }) => (typeof value === 'string' ? value.split(',') : value))
  periods!: string[];
}
