28 lines
755 B
C#
28 lines
755 B
C#
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("L’ISBN est obligatoire.")
|
||
.Matches(@"^\d{13}$")
|
||
.WithMessage("L’ISBN doit contenir exactement 13 chiffres.");
|
||
|
||
RuleFor(x => x.AuthorFullName)
|
||
.NotEmpty()
|
||
.WithMessage("AuthorFullName is required");
|
||
}
|
||
} |