Files
schengen-visa/SchengenVisaApi/BlazorWebAssemblyVisaApiClient/FluentValidation/Applicants/Validators/NameModelValidator.cs
2024-09-01 17:47:49 +03:00

27 lines
1003 B
C#

using FluentValidation;
using VisaApiClient;
namespace BlazorWebAssemblyVisaApiClient.FluentValidation.Applicants.Validators;
public class NameModelValidator : AbstractValidator<NameModel>
{
public NameModelValidator()
{
RuleFor(m => m.FirstName)
.NotEmpty()
.WithMessage("First Name can not be empty")
.MaximumLength(ConfigurationConstraints.NameLength)
.WithMessage($"First Name length must be less than {ConfigurationConstraints.NameLength}");
RuleFor(m => m.Surname)
.NotEmpty()
.WithMessage("Surname can not be empty")
.MaximumLength(ConfigurationConstraints.NameLength)
.WithMessage($"Surname length must be less than {ConfigurationConstraints.NameLength}");
RuleFor(m => m.Patronymic)
.MaximumLength(ConfigurationConstraints.NameLength)
.WithMessage($"Patronymic length must be less than {ConfigurationConstraints.NameLength}");
}
}