You can implement the IValidatableObject interface
Something like that:
public class MyObject : IValidatableObject
{
public IList<AccountAddress> BulkOrderAddresses { get; set; }
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if(BulkOrderAddresses == null && !BulkOrderAddresses.Length > 2)
{
yield return new ValidationResult("List should contain more than 2 items");
}
}
}
source
share