Files
dzone-api/src/modules/tickets/DTO/create-ticket.dto.ts
T
2025-05-13 09:45:21 +03:30

43 lines
2.1 KiB
TypeScript
Executable File

import { ApiProperty } from "@nestjs/swagger";
import { ArrayMinSize, IsEnum, IsNotEmpty, IsOptional, IsString, IsUUID, IsUrl, Length } from "class-validator";
import { TicketMessageEnum } from "../../../common/enums/message.enum";
import { TicketPriority } from "../enums/ticket-priority.enum";
export class CreateTicketDto {
@IsNotEmpty({ message: TicketMessageEnum.SUBJECT_REQUIRED })
@IsString({ message: TicketMessageEnum.SUBJECT_STRING })
@Length(3, 150, { message: TicketMessageEnum.SUBJECT_LENGTH })
@ApiProperty({ description: "Subject of the ticket", example: "Subject" })
subject: string;
@IsNotEmpty({ message: TicketMessageEnum.PRIORITY_REQUIRED })
@IsEnum(TicketPriority, { message: TicketMessageEnum.PRIORITY_INVALID })
@ApiProperty({ enum: TicketPriority, example: TicketPriority.LOW, description: "LOW, MEDIUM, HIGH" })
priority: TicketPriority;
@IsOptional()
@IsNotEmpty({ message: TicketMessageEnum.COMPANY_ID_REQUIRED })
@IsUUID("7", { message: TicketMessageEnum.COMPANY_ID_SHOULD_BE_UUID })
@ApiProperty({ description: "Company ID related to the ticket", example: "550e8400-e29b-41d4-a716-446655440000" })
companyId?: string;
@IsNotEmpty({ message: TicketMessageEnum.CATEGORY_ID_REQUIRED })
@IsUUID("4", { message: TicketMessageEnum.CATEGORY_ID_SHOULD_BE_UUID })
@ApiProperty({ description: "Category ID of the ticket", example: "123e4567-e89b-12d3-a456-426614174000" })
categoryId: string;
@IsNotEmpty({ message: TicketMessageEnum.MESSAGE_REQUIRED })
@IsString({ message: TicketMessageEnum.MESSAGE_STRING })
@Length(5, 500, { message: TicketMessageEnum.MESSAGE_LENGTH })
@ApiProperty({ description: "The message content of the ticket", example: "This is a detailed description of the issue." })
message: string;
@IsOptional()
@IsNotEmpty({ message: TicketMessageEnum.ATTACHMENT_REQUIRED })
@ArrayMinSize(1, { message: TicketMessageEnum.ATTACHMENT_REQUIRED })
@IsUrl({ protocols: ["http", "https"], require_protocol: true }, { each: true, message: TicketMessageEnum.ATTACHMENT_SHOULD_BE_URL })
@ApiProperty({ description: "attachment url", example: ["https://example.com/test.png"] })
attachmentUrls?: string[];
}