import { IsString, IsOptional, IsEnum, IsArray, MinLength, MaxLength } from "class-validator";
import { EntryStatus, Visibility } from "@prisma/client";

/**
 * DTO for creating a new knowledge entry
 */
export class CreateEntryDto {
  @IsString({ message: "title must be a string" })
  @MinLength(1, { message: "title must not be empty" })
  @MaxLength(500, { message: "title must not exceed 500 characters" })
  title!: string;

  @IsString({ message: "content must be a string" })
  @MinLength(1, { message: "content must not be empty" })
  content!: string;

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

  @IsOptional()
  @IsEnum(EntryStatus, { message: "status must be a valid EntryStatus" })
  status?: EntryStatus;

  @IsOptional()
  @IsEnum(Visibility, { message: "visibility must be a valid Visibility" })
  visibility?: Visibility;

  @IsOptional()
  @IsArray({ message: "tags must be an array" })
  @IsString({ each: true, message: "each tag must be a string" })
  tags?: string[];

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