1
下面我有三個不同的類別。帶Bools的數據註釋
我將如何構造驗證以確保每個類別至少選擇一個布爾值?
//殘疾人
[Display(Name = "Learning Disabilities")]
public bool LD { get; set; }
[Display(Name = "Developmental Disabilities")]
public bool DD { get; set; }
[Display(Name = "AD/HD")]
public bool ADHD { get; set; }
[Display(Name = "Autism")]
public bool Autism { get; set; }
//年齡組
[Display(Name = "Child")]
public bool child { get; set; }
[Display(Name = "Youth")]
public bool youth { get; set; }
[Display(Name = "Adult")]
public bool adult { get; set; }
//策略類型
[Display(Name = "Academic")]
public bool academic { get; set; }
[Display(Name = "Behaviour")]
public bool behaviour { get; set; }
[Display(Name = "Communication")]
public bool communication { get; set; }
[Display(Name = "Social")]
public bool social { get; set; }
可能重複。如何設置驗證,要求兩個字段之一取決於模型的布爾值?](http://stackoverflow.com/questions/11143151/asp-net-mvc3-how-to-set-validation-to-require-之一的兩字段-取決於-ON-BO) – MarcinJuraszek