using FluentValidation; using Landmark.OLA.Models.Individuals.Enums; namespace Landmark.OLA.Models.HomeMortgageDisclosureAct.Validators { public class HmdaValidator : AbstractValidator { public HmdaValidator() { RuleFor(x => x.Races).NotEmpty() .WithMessage($"No race information was provided. Set {Race.NotProvided} if none will be provided."); RuleFor(x => x.Races).Must(races => races.Contains(Race.AmericanIndianAlaskaNative)) .When(x => !string.IsNullOrWhiteSpace(x.AmericanIndianAlaskaNativeTribe)) .WithMessage($"Include {Race.AmericanIndianAlaskaNative} in Races when a value is set in AmericanIndianAlaskaNativeTribe."); RuleFor(x => x.Races).Must(races => races.Contains(Race.OtherAsian)) .When(x => !string.IsNullOrWhiteSpace(x.OtherAsianRace)) .WithMessage($"Include {Race.OtherAsian} in Races when a value is set in OtherAsianRace."); RuleFor(x => x.Races).Must(races => races.Contains(Race.OtherPacificIslander)) .When(x => !string.IsNullOrWhiteSpace(x.OtherPacificIslanderRace)) .WithMessage($"Include {Race.OtherPacificIslander} in Races when a value is set in OtherPacificIslanderRace."); RuleFor(x => x.Ethnicities).NotEmpty() .WithMessage($"No ethnicity information was provided. Set {Ethnicity.NotProvided} if none will be provided."); RuleFor(x => x.Ethnicities).Must(ethnicities => ethnicities.Contains(Ethnicity.OtherHispanicLatino)) .When(x => !string.IsNullOrWhiteSpace(x.OtherHispanicLatinoEthnicity)) .WithMessage($"Include {Ethnicity.OtherHispanicLatino} in Ethnicities when a value is set in OtherHispanicLatinoEthnicity."); RuleFor(x => x.Sexes).NotEmpty() .WithMessage($"No sex information was provided. Set {Sex.NotProvided} if none will be provided."); } } }