I am new to MVC, recently I am working on the data validation, and I was wondering that in stead of giving a validation annotation for each parameter, is there a way that I can define validation rules for a group of parameters in a class? For example, a class is like this:
namespace MvcApplication1.Models
{
public class Product
{
public int Id { get; set; }
[Required]
[StringLength(10)]
public string Param1 { get; set; }
[Required]
public string Param2 { get; set; }
[DisplayName("Param3")]
[Required]
public string Param3 { get; set; }
}
}
Is there a way to define a rule that for Param1, Param2, and Param3, for example, at least 2 of them are required?