if anyone has much experience using [C#] FluentValidation and has any ideas for the below question any help would be much appreciated.
I have 2 Generic Lists (both with
I ended up using the following FluentValidation code to check the corrosponding items in each list, big thanks to Guvante as it was inspired by his Pseudo-code :)
RuleFor(f => f.Names).Must((f, d) =>
{
for (int i = 0; i < d.Count; i++)
{
if ((String.IsNullOrEmpty(d[i]) &&
!String.IsNullOrEmpty(f.URLs[i])))
return false;
}
return true;
})
.WithMessage("Names cannot be empty.");
RuleFor(f => f.URLs).Must((f, u) =>
{
for (int i = 0; i < u.Count; i++)
{
if ((String.IsNullOrEmpty(u[i]) &&
!String.IsNullOrEmpty(f.Names[i])))
return false;
}
return true;
})
.WithMessage("URLs cannot be empty.");