import { IsString, IsOptional, MinLength, MaxLength, Matches, IsObject } from "class-validator";

/**
 * DTO for updating an existing domain
 * All fields are optional to support partial updates
 */
export class UpdateDomainDto {
  @IsOptional()
  @IsString({ message: "name must be a string" })
  @MinLength(1, { message: "name must not be empty" })
  @MaxLength(255, { message: "name must not exceed 255 characters" })
  name?: string;

  @IsOptional()
  @IsString({ message: "slug must be a string" })
  @MinLength(1, { message: "slug must not be empty" })
  @MaxLength(100, { message: "slug must not exceed 100 characters" })
  @Matches(/^[a-z0-9-]+$/, {
    message: "slug must contain only lowercase letters, numbers, and hyphens",
  })
  slug?: string;

  @IsOptional()
  @IsString({ message: "description must be a string" })
  @MaxLength(10000, { message: "description must not exceed 10000 characters" })
  description?: string | null;

  @IsOptional()
  @IsString({ message: "color must be a string" })
  @Matches(/^#[0-9A-F]{6}$/i, {
    message: "color must be a valid hex color code (e.g., #FF5733)",
  })
  color?: string | null;

  @IsOptional()
  @IsString({ message: "icon must be a string" })
  @MaxLength(50, { message: "icon must not exceed 50 characters" })
  icon?: string | null;

  @IsOptional()
  @IsObject({ message: "metadata must be an object" })
  metadata?: Record<string, unknown>;
}
