diff --git a/src/goals/dto.ts b/src/goals/dto.ts new file mode 100644 index 0000000..01c65e3 --- /dev/null +++ b/src/goals/dto.ts @@ -0,0 +1,47 @@ +import { IsArray, IsIn, IsOptional, IsString, Length } from 'class-validator'; + +export const GOAL_STATUSES = ['not_started', 'on_track', 'at_risk', 'achieved', 'abandoned'] as const; +export type GoalStatusValue = (typeof GOAL_STATUSES)[number]; + +export class CreateGoalDto { + @IsString() + @Length(1, 500) + horizon!: string; + + @IsString() + @Length(1, 500) + metric!: string; + + @IsString() + @Length(1, 1000) + target!: string; + + @IsOptional() + @IsArray() + milestones?: unknown[]; +} + +export class UpdateGoalDto { + @IsOptional() + @IsString() + @Length(1, 500) + horizon?: string; + + @IsOptional() + @IsString() + @Length(1, 500) + metric?: string; + + @IsOptional() + @IsString() + @Length(1, 1000) + target?: string; + + @IsOptional() + @IsArray() + milestones?: unknown[]; + + @IsOptional() + @IsIn(GOAL_STATUSES as unknown as string[]) + status?: GoalStatusValue; +}