import { IsString, IsNotEmpty, IsArray, ArrayMinSize } from "class-validator"
import { ApiProperty } from "@nestjs/swagger"
import { validationMessage } from "src/utils/helpers"
import { messageKey } from "src/constants/message-keys"

export class CreateInspectionQuestionDto {
  @ApiProperty({ example: "Are seatbelts functional in all seats?" })
  @IsString()
  @IsNotEmpty({
    message: validationMessage(messageKey.field_required, {
      ":field": "question text",
    }),
  })
  question_text: string

  @ApiProperty({
    example: ["Yes", "No", "Not Applicable"],
    description: "List of answer options",
    type: [String],
  })
  @IsArray()
  @ArrayMinSize(1, {
    message: validationMessage(messageKey.field_required, {
      ":field": "answer options",
    }),
  })
  @IsString({ each: true, message: "Each answer option must be a string." })
  answer_options: string[]
}
