import { IsString, IsOptional, IsNumber, IsBoolean, Min, Max } from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';

/**
 * DTO for creating a new user address.
 */
export class CreateUserAddressDto {
  @ApiProperty({ description: 'Address title/label (e.g., "Home", "Work")', example: 'Home' })
  @IsString()
  title!: string;

  @ApiProperty({ description: 'Street address', example: '123 Main Street' })
  @IsString()
  address!: string;

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

  @ApiPropertyOptional({ description: 'Province', example: 'Tehran Province' })
  @IsOptional()
  @IsString()
  province?: string;

  @ApiPropertyOptional({ description: 'Postal/ZIP code', example: '12345-6789' })
  @IsOptional()
  @IsString()
  postalCode?: string;

  @ApiProperty({ description: 'Latitude coordinate', example: 35.6892, minimum: -90, maximum: 90 })
  @IsNumber()
  @Min(-90)
  @Max(90)
  latitude!: number;

  @ApiProperty({ description: 'Longitude coordinate', example: 51.389, minimum: -180, maximum: 180 })
  @IsNumber()
  @Min(-180)
  @Max(180)
  longitude!: number;

  @ApiPropertyOptional({ description: 'Contact phone for this address', example: '+989123456789' })
  @IsOptional()
  @IsString()
  phone?: string;

  @ApiPropertyOptional({ description: 'Set as default address', example: false, default: false })
  @IsOptional()
  @IsBoolean()
  isDefault?: boolean;
}
