I ended up solving the problem by using a custom DataAnnotation -- did not think to see if this could be done first!
Here is my code if it helps anyone else!
/// <summary>
/// Require a minimum length, and optionally a maximum length, for any IEnumerable
/// </summary>
sealed public class CollectionMinimumLengthValidationAttribute : ValidationAttribute
{
const string errorMessage = "{0} must contain at least {1} item(s).";
const string errorMessageWithMax = "{0} must contain between {1} and {2} item(s).";
int minLength;
int? maxLength;
public CollectionMinimumLengthValidationAttribute(int min)
{
minLength = min;
maxLength = null;
}
public CollectionMinimumLengthValidationAttribute(int min,int max)
{
minLength = min;
maxLength = max;
}
//Override default FormatErrorMessage Method
public override string FormatErrorMessage(string name)
{
if(maxLength != null)
{
return string.Format(errorMessageWithMax,name,minLength,maxLength.Value);
}
else
{
return string.Format(errorMessage, name, minLength);
}
}
public override bool IsValid(object value)
{
IEnumerable<object> list = value as IEnumerable<object>;
if (list != null && list.Count() >= minLength && (maxLength == null || list.Count() <= maxLength))
{
return true;
}
else
{
return false;
}
}
}
}