Initial commit

This commit is contained in:
Kevin Harlay
2026-09-07 13:33:22 +02:00
commit ebfaf6f5ec
295 changed files with 8786 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
using ExpenseTracker.Api.DTOs;
using FluentValidation;
namespace ExpenseTracker.Api.Validators;
public class CreateCategoryDtoValidator : AbstractValidator<CreateCategoryDto>
{
public CreateCategoryDtoValidator()
{
RuleFor(x => x.Name)
.NotEmpty()
.WithMessage("Name is required.")
.MaximumLength(100)
.WithMessage("Name must not exceed 100 characters.");
RuleFor(x => x.Color)
.NotEmpty()
.WithMessage("Color is required.")
.Matches(@"^#[0-9A-Fa-f]{6}$")
.WithMessage("Color must be a valid hex color in the format #RRGGBB.");
}
}
+35
View File
@@ -0,0 +1,35 @@
using ExpenseTracker.Api.DTOs;
using FluentValidation;
namespace ExpenseTracker.Api.Validators;
public class CreateEntryDtoValidator : AbstractValidator<CreateEntryDto>
{
public CreateEntryDtoValidator()
{
RuleFor(x => x.Type)
.NotEmpty()
.WithMessage("Type is required.")
.Must(t => t == "INCOME" || t == "EXPENSE")
.WithMessage("Type must be INCOME or EXPENSE.");
RuleFor(x => x.Amount)
.GreaterThan(0)
.WithMessage("Amount must be greater than 0.");
RuleFor(x => x.Label)
.NotEmpty()
.WithMessage("Label is required.")
.MaximumLength(200)
.WithMessage("Label must not exceed 200 characters.");
RuleFor(x => x.EntryDate)
.NotEqual(default(DateOnly))
.WithMessage("EntryDate is required.");
RuleFor(x => x.CategoryId)
.NotNull()
.WithMessage("CategoryId is required for EXPENSE entries.")
.When(x => x.Type == "EXPENSE");
}
}
+22
View File
@@ -0,0 +1,22 @@
using ExpenseTracker.Api.DTOs;
using FluentValidation;
namespace ExpenseTracker.Api.Validators;
public class CreateMonthDtoValidator : AbstractValidator<CreateMonthDto>
{
public CreateMonthDtoValidator()
{
RuleFor(x => x.Year)
.GreaterThanOrEqualTo(2000)
.WithMessage("Year must be 2000 or later.");
RuleFor(x => x.Month)
.InclusiveBetween(1, 12)
.WithMessage("Month must be between 1 and 12.");
RuleFor(x => x.DefaultSalary)
.GreaterThanOrEqualTo(0)
.WithMessage("DefaultSalary must be zero or positive.");
}
}
@@ -0,0 +1,14 @@
using ExpenseTracker.Api.DTOs;
using FluentValidation;
namespace ExpenseTracker.Api.Validators;
public class UpdateDefaultSalaryDtoValidator : AbstractValidator<UpdateDefaultSalaryDto>
{
public UpdateDefaultSalaryDtoValidator()
{
RuleFor(x => x.Value)
.GreaterThanOrEqualTo(0)
.WithMessage("Value must be greater than or equal to 0.");
}
}
+35
View File
@@ -0,0 +1,35 @@
using ExpenseTracker.Api.DTOs;
using FluentValidation;
namespace ExpenseTracker.Api.Validators;
public class UpdateEntryDtoValidator : AbstractValidator<UpdateEntryDto>
{
public UpdateEntryDtoValidator()
{
RuleFor(x => x.Type)
.NotEmpty()
.WithMessage("Type is required.")
.Must(t => t == "INCOME" || t == "EXPENSE")
.WithMessage("Type must be INCOME or EXPENSE.");
RuleFor(x => x.Amount)
.GreaterThan(0)
.WithMessage("Amount must be greater than 0.");
RuleFor(x => x.Label)
.NotEmpty()
.WithMessage("Label is required.")
.MaximumLength(200)
.WithMessage("Label must not exceed 200 characters.");
RuleFor(x => x.EntryDate)
.NotEqual(default(DateOnly))
.WithMessage("EntryDate is required.");
RuleFor(x => x.CategoryId)
.NotNull()
.WithMessage("CategoryId is required for EXPENSE entries.")
.When(x => x.Type == "EXPENSE");
}
}