27 lines
938 B
C#
27 lines
938 B
C#
using FluentValidation;
|
|
|
|
namespace Landmark.OLA.Models.Individuals.Validators
|
|
{
|
|
class ApplicantValidator : AbstractValidator<IApplicant>
|
|
{
|
|
public ApplicantValidator()
|
|
{
|
|
RuleForEach(x => x.Employers).SetValidator(new EmployerValidator());
|
|
|
|
When(x => x.DetailedNonApplicantSpouse is not null, () =>
|
|
{
|
|
RuleForEach(x => x.DetailedNonApplicantSpouse.Employers).SetValidator(new EmployerValidator());
|
|
});
|
|
|
|
When(x => x.NonApplicantSpouse is not null, () =>
|
|
{
|
|
//An individual can only have a single spouse entry
|
|
RuleFor(x => x.DetailedNonApplicantSpouse).Null();
|
|
});
|
|
|
|
RuleFor(x => x.SecondaryPhoneType).NotNull().When(x => x.SecondaryPhone?.Length > 0)
|
|
.WithMessage("SecondaryPhoneType must be set when a SecondaryPhone value is present.");
|
|
}
|
|
}
|
|
}
|