first commit
This commit is contained in:
+33
@@ -0,0 +1,33 @@
|
||||
using FluentValidation;
|
||||
|
||||
namespace Landmark.OLA.Models.Loan.Validators
|
||||
{
|
||||
public class BranchConfigValidator : AbstractValidator<BranchConfig>
|
||||
{
|
||||
public BranchConfigValidator() {
|
||||
RuleFor(x => x.BranchCodesByZip).Must((x, branchCodes) => NoZipcodeDuplicates(branchCodes))
|
||||
.WithMessage("You cannot have duplicate zipcodes.");
|
||||
}
|
||||
|
||||
private static bool NoZipcodeDuplicates(List<BranchData> branchData)
|
||||
{
|
||||
var matchFound = false;
|
||||
foreach (var eachMapping in branchData)
|
||||
{
|
||||
int matchCount = 0;
|
||||
foreach (var otherMapping in branchData)
|
||||
{
|
||||
if( otherMapping.Zipcode == eachMapping.Zipcode)
|
||||
{
|
||||
matchCount++;
|
||||
}
|
||||
}
|
||||
if( matchCount > 1 )
|
||||
{
|
||||
matchFound = true;
|
||||
}
|
||||
}
|
||||
return !matchFound;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user