added validators in project

This commit is contained in:
2026-03-10 09:52:31 +01:00
parent 2e7b9e5154
commit 9f858df5f8
17 changed files with 558 additions and 188 deletions

View File

@@ -0,0 +1,28 @@
using BookHive.DTO.Book;
using FastEndpoints;
using FluentValidation;
namespace BookHive.Validators.Books;
public class GetBookDtoValidator : Validator<GetBookDto>
{
public GetBookDtoValidator()
{
RuleFor(x => x.Id)
.GreaterThan(0)
.WithMessage("Id is invalid");
RuleFor(x => x.Title)
.NotEmpty()
.WithMessage("Title is required");
RuleFor(x => x.Isbn)
.NotEmpty().WithMessage("LISBN est obligatoire.")
.Matches(@"^\d{13}$")
.WithMessage("LISBN doit contenir exactement 13 chiffres.");
RuleFor(x => x.AuthorFullName)
.NotEmpty()
.WithMessage("AuthorFullName is required");
}
}