Files
stack/apps/api/src/tasks/dto/create-task.dto.ts
Jason Woltje 1df20f0e13
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
feat(api): add assigned_agent to Task model (MS22-DB-003, MS22-API-003) (#591)
Co-authored-by: Jason Woltje <jason@diversecanvas.com>
Co-committed-by: Jason Woltje <jason@diversecanvas.com>
2026-03-01 03:54:28 +00:00

68 lines
1.8 KiB
TypeScript

import { TaskStatus, TaskPriority } from "@prisma/client";
import {
IsString,
IsOptional,
IsUUID,
IsEnum,
IsDateString,
IsInt,
IsObject,
MinLength,
MaxLength,
Min,
} from "class-validator";
/**
* DTO for creating a new task
*/
export class CreateTaskDto {
@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()
@IsEnum(TaskStatus, { message: "status must be a valid TaskStatus" })
status?: TaskStatus;
@IsOptional()
@IsEnum(TaskPriority, { message: "priority must be a valid TaskPriority" })
priority?: TaskPriority;
@IsOptional()
@IsDateString({}, { message: "dueDate must be a valid ISO 8601 date string" })
dueDate?: Date;
@IsOptional()
@IsUUID("4", { message: "assigneeId must be a valid UUID" })
assigneeId?: string;
@IsOptional()
@IsUUID("4", { message: "projectId must be a valid UUID" })
projectId?: string;
@IsOptional()
@IsUUID("4", { message: "parentId must be a valid UUID" })
parentId?: string;
@IsOptional()
@IsString({ message: "assignedAgent must be a string" })
@MinLength(1, { message: "assignedAgent must not be empty" })
@MaxLength(255, { message: "assignedAgent must not exceed 255 characters" })
assignedAgent?: string;
@IsOptional()
@IsInt({ message: "sortOrder must be an integer" })
@Min(0, { message: "sortOrder must be at least 0" })
sortOrder?: number;
@IsOptional()
@IsObject({ message: "metadata must be an object" })
metadata?: Record<string, unknown>;
}