Files
WatchIt/WatchIt.DTO/Models/Controllers/People/Person/PersonRequestValidator.cs

22 lines
653 B
C#
Raw Normal View History

2024-10-02 16:09:11 +02:00
using FluentValidation;
2024-10-04 19:32:25 +02:00
using WatchIt.Database;
2024-10-02 16:09:11 +02:00
namespace WatchIt.DTO.Models.Controllers.People.Person;
2024-10-02 16:09:11 +02:00
public class PersonRequestValidator : AbstractValidator<PersonRequest>
{
#region CONSTRUCTORS
2024-10-04 19:32:25 +02:00
public PersonRequestValidator(DatabaseContext database)
{
RuleFor(x => x.Name).NotEmpty()
.MaximumLength(100);
2024-10-04 19:32:25 +02:00
RuleFor(x => x.FullName).MaximumLength(200);
RuleFor(x => x.Description).MaximumLength(1000);
When(x => x.GenderId.HasValue, () =>
{
RuleFor(x => x.GenderId!.Value).MustBeIn(database.Genders.Select(g => g.Id));
});
}
#endregion
2024-10-02 16:09:11 +02:00
}