Files
stack/apps/api/src/projects/dto/create-project.dto.ts
Jason Woltje e7da4ca25e
Some checks failed
ci/woodpecker/push/ci Pipeline failed
fix: attach domain to project (#640)
Co-authored-by: Jason Woltje <jason@diversecanvas.com>
Co-committed-by: Jason Woltje <jason@diversecanvas.com>
2026-03-01 22:33:49 +00:00

55 lines
1.4 KiB
TypeScript

import { ProjectStatus } from "@prisma/client";
import {
IsString,
IsOptional,
IsEnum,
IsDateString,
IsObject,
MinLength,
MaxLength,
Matches,
IsUUID,
} from "class-validator";
/**
* DTO for creating a new project
*/
export class CreateProjectDto {
@IsString({ message: "name must be a string" })
@MinLength(1, { message: "name must not be empty" })
@MaxLength(255, { message: "name must not exceed 255 characters" })
name!: string;
@IsOptional()
@IsString({ message: "description must be a string" })
@MaxLength(10000, { message: "description must not exceed 10000 characters" })
description?: string;
@IsOptional()
@IsEnum(ProjectStatus, { message: "status must be a valid ProjectStatus" })
status?: ProjectStatus;
@IsOptional()
@IsDateString({}, { message: "startDate must be a valid ISO 8601 date string" })
startDate?: Date;
@IsOptional()
@IsDateString({}, { message: "endDate must be a valid ISO 8601 date string" })
endDate?: Date;
@IsOptional()
@IsString({ message: "color must be a string" })
@Matches(/^#[0-9A-F]{6}$/i, {
message: "color must be a valid hex color code (e.g., #FF5733)",
})
color?: string;
@IsOptional()
@IsUUID("4", { message: "domainId must be a valid UUID" })
domainId?: string;
@IsOptional()
@IsObject({ message: "metadata must be an object" })
metadata?: Record<string, unknown>;
}