import { ApiPropertyOptional } from "@nestjs/swagger"
import { IsString, IsIn, IsOptional } from "class-validator"
import { messageKey } from "src/constants/message-keys"
import { validationMessage } from "src/utils/helpers"
import { CONTENT_FORMAT_VALUES } from "src/constants/app-content.constant"

export class CreateAppContentDto {
  @ApiPropertyOptional({
    description:
      "Title (plain text or HTML depending on title_format). Either title or description must be provided.",
    example: "Welcome to Big Happy",
  })
  @IsOptional()
  @IsString()
  title?: string

  @ApiPropertyOptional({
    description: "Title format (text or html)",
    example: "text",
    default: "text",
  })
  @IsOptional()
  @IsString()
  @IsIn(CONTENT_FORMAT_VALUES, {
    message: validationMessage(messageKey.invalid, {
      ":field": "title_format",
    }),
  })
  title_format?: string

  @ApiPropertyOptional({
    description:
      "Description (plain text or HTML depending on description_format). Either title or description must be provided.",
    example: "Start your day with an intention.",
  })
  @IsOptional()
  @IsString()
  description?: string

  @ApiPropertyOptional({
    description: "Description format (text or html)",
    example: "html",
    default: "text",
  })
  @IsOptional()
  @IsString()
  @IsIn(CONTENT_FORMAT_VALUES, {
    message: validationMessage(messageKey.invalid, {
      ":field": "description_format",
    }),
  })
  description_format?: string
}
