I have a ValidationAttribute
like below which validates that a certain amount of values have been entered on a form. Currently it is only being used on a property with type short?[]
public class RequiredArrayLength : ValidationAttribute
{
public int TotalRequired { get; set; }
public override bool IsValid(object value)
{
if(value != null)
{
var array = value as short?[];
return array.Where(v => v.HasValue).Count() >= TotalRequired;
}
return false;
}
}
Is there a way I can modify this ValidationAttribute
so it will work with other numeric arrays such as int?[]