finance-api/src/modules/goals/dto/create-goal.dto.ts
Заид Омар Медхат 33602d0fe9 chore: initialize NestJS project with Docker and environment configuration
Add project scaffolding and development infrastructure:
- Add environment configuration files (.env.development, .env.example) with database, JWT, security, AI integration, logging, and CORS settings
- Add .gitignore to exclude build artifacts, logs, IDE files, and environment variables
- Add .prettierrc with single quotes and trailing commas configuration
- Add multi-stage Dockerfile with development, build, and production stages
- Ad
2025-12-13 15:45:08 +05:00

111 lines
3.2 KiB
TypeScript

import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import {
IsString,
IsNumber,
IsEnum,
IsOptional,
IsDateString,
IsBoolean,
Min,
Max,
MaxLength,
Matches,
} from 'class-validator';
import { GoalPriority } from '../entities/goal.entity';
export class CreateGoalDto {
@ApiProperty({
description: 'Название цели',
example: 'Накопить на отпуск',
})
@IsString({ message: 'Название должно быть строкой' })
@MaxLength(200, { message: 'Название не должно превышать 200 символов' })
titleRu: string;
@ApiPropertyOptional({
description: 'Описание цели',
example: 'Поездка в Турцию на 2 недели',
})
@IsOptional()
@IsString({ message: 'Описание должно быть строкой' })
descriptionRu?: string;
@ApiProperty({
description: 'Целевая сумма в рублях',
example: 150000,
})
@IsNumber({}, { message: 'Сумма должна быть числом' })
@Min(1, { message: 'Сумма должна быть положительным числом' })
@Max(1000000000, { message: 'Сумма превышает допустимый лимит' })
targetAmount: number;
@ApiPropertyOptional({
description: 'Начальная сумма',
example: 10000,
})
@IsOptional()
@IsNumber({}, { message: 'Сумма должна быть числом' })
@Min(0, { message: 'Сумма не может быть отрицательной' })
currentAmount?: number;
@ApiPropertyOptional({
description: 'Целевая дата достижения (YYYY-MM-DD)',
example: '2024-12-31',
})
@IsOptional()
@IsDateString({}, { message: 'Некорректный формат даты' })
targetDate?: string;
@ApiPropertyOptional({
description: 'Приоритет цели',
enum: GoalPriority,
example: 'HIGH',
})
@IsOptional()
@IsEnum(GoalPriority, { message: 'Приоритет должен быть LOW, MEDIUM или HIGH' })
priority?: GoalPriority;
@ApiPropertyOptional({
description: 'Иконка цели',
example: 'plane',
})
@IsOptional()
@IsString()
@MaxLength(50)
icon?: string;
@ApiPropertyOptional({
description: 'Цвет в HEX формате',
example: '#4CAF50',
})
@IsOptional()
@Matches(/^#[0-9A-Fa-f]{6}$/, { message: 'Цвет должен быть в формате HEX' })
color?: string;
@ApiPropertyOptional({
description: 'Включить автоматическое накопление',
example: true,
})
@IsOptional()
@IsBoolean()
autoSaveEnabled?: boolean;
@ApiPropertyOptional({
description: 'Сумма автоматического накопления',
example: 5000,
})
@IsOptional()
@IsNumber()
@Min(0)
autoSaveAmount?: number;
@ApiPropertyOptional({
description: 'Частота автоматического накопления',
enum: ['DAILY', 'WEEKLY', 'MONTHLY'],
example: 'MONTHLY',
})
@IsOptional()
@IsEnum(['DAILY', 'WEEKLY', 'MONTHLY'])
autoSaveFrequency?: 'DAILY' | 'WEEKLY' | 'MONTHLY';
}