PersonEditFormComponent added

This commit is contained in:
2024-10-04 19:32:25 +02:00
Unverified
parent 9f3bbcf987
commit b43b319855
7 changed files with 163 additions and 3 deletions

View File

@@ -1,9 +1,19 @@
using FluentValidation;
using WatchIt.Common.Model.Persons;
using WatchIt.Database;
namespace WatchIt.WebAPI.Validators.Persons;
public class PersonRequestValidator : AbstractValidator<PersonRequest>
{
public PersonRequestValidator(DatabaseContext database)
{
RuleFor(x => x.Name).NotEmpty().MaximumLength(100);
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));
});
}
}