Initial commit
This commit is contained in:
@@ -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.");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user