import {
  IsString,
  IsOptional,
  IsUUID,
  IsDateString,
  IsBoolean,
  IsObject,
  MinLength,
  MaxLength,
} from "class-validator";

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

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

  @IsOptional()
  @IsDateString({}, { message: "startTime must be a valid ISO 8601 date string" })
  startTime?: Date;

  @IsOptional()
  @IsDateString({}, { message: "endTime must be a valid ISO 8601 date string" })
  endTime?: Date;

  @IsOptional()
  @IsBoolean({ message: "allDay must be a boolean" })
  allDay?: boolean;

  @IsOptional()
  @IsString({ message: "location must be a string" })
  @MaxLength(500, { message: "location must not exceed 500 characters" })
  location?: string;

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

  @IsOptional()
  @IsUUID("4", { message: "projectId must be a valid UUID" })
  projectId?: string;

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