import { Transform, Type } from 'class-transformer';
import {
  ArrayMaxSize,
  IsArray,
  IsNumber,
  IsOptional,
  IsString,
  IsUrl,
  Length,
  Max,
  Min,
} from 'class-validator';
import { toStringArray } from '../../../common/utils/array-transform.util';

export class UpdateShopProfileDto {
  @IsOptional()
  @IsString()
  @Length(2, 120)
  shopName?: string;

  @IsOptional()
  @IsString()
  @Length(0, 2000)
  shopDescription?: string;

  @IsOptional()
  @Transform(toStringArray)
  @IsArray()
  @ArrayMaxSize(8)
  @IsUrl({ require_tld: false }, { each: true })
  shopImageUrls?: string[];

  @IsOptional()
  @IsString()
  @Length(0, 160)
  shopLocation?: string;

  @IsOptional()
  @Type(() => Number)
  @IsNumber()
  @Min(-90)
  @Max(90)
  shopLatitude?: number;

  @IsOptional()
  @Type(() => Number)
  @IsNumber()
  @Min(-180)
  @Max(180)
  shopLongitude?: number;
}
