import { ApiProperty } from "@nestjs/swagger"
import { Transform } from "class-transformer"
import { IsNotEmpty, IsString } from "class-validator"

export class UpsertLocationDto {
  @ApiProperty({
    description:
      "Country name. If it exists, it will be reused; otherwise it will be created.",
    example: "India",
  })
  @IsString({ message: "Country name must be a string." })
  @Transform(({ value }) => value?.trim())
  @IsNotEmpty({ message: "Country name cannot be empty." })
  country: string

  @ApiProperty({
    description:
      "State name. Must belong to the given country. If it doesn't exist, it will be created.",
    example: "Gujarat",
  })
  @IsString({ message: "State name must be a string." })
  @Transform(({ value }) => value?.trim())
  @IsNotEmpty({ message: "State name cannot be empty." })
  state: string

  @ApiProperty({
    description:
      "City name. Must belong to the given state. Will be created if not found.",
    example: "Ahmedabad",
  })
  @IsString({ message: "City name must be a string." })
  @Transform(({ value }) => value?.trim())
  @IsNotEmpty({ message: "City name cannot be empty." })
  city: string
}
