added validators in project
This commit is contained in:
23
BookHive/Validators/Authors/GetAuthorDtoValidator.cs
Normal file
23
BookHive/Validators/Authors/GetAuthorDtoValidator.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using BookHive.DTO.Author;
|
||||
using FastEndpoints;
|
||||
using FluentValidation;
|
||||
|
||||
namespace BookHive.Validators.Authors;
|
||||
|
||||
public class GetAuthorDtoValidator : Validator<GetAuthorDto>
|
||||
{
|
||||
public GetAuthorDtoValidator()
|
||||
{
|
||||
RuleFor(x => x.Id)
|
||||
.GreaterThan(0)
|
||||
.WithMessage("Id is invalid");
|
||||
|
||||
RuleFor(x => x.FirstName)
|
||||
.NotEmpty()
|
||||
.WithMessage("First name is required");
|
||||
|
||||
RuleFor(x => x.LastName)
|
||||
.NotEmpty()
|
||||
.WithMessage("Last name is required");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user