Files
TP-Fluent/BookHive/Validators/Books/GetBookDtoValidator.cs
2026-03-17 10:27:53 +01:00

28 lines
739 B
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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");
}
}