Tôi đang sử dụng System.ComponentModel.DataAnnotations tha namespace trong C# 4 để thực hiện thuộc tính xác nhận của riêng tôi và nó trông như thế nàyTuỳ chỉnh xác nhận với vấn đề nhiều trường
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
public sealed class MyCustomValidator : ValidationAttribute {
private String Property1 { get; set; }
private String Property2 { get; set; }
public ValeTaxiSituacaoRequired(String property1, String property2) {
Property1 = property1;
Property2 = property2;
}
public override bool IsValid(object value) {
//validation logic
}
}
Tôi muốn sử dụng thuộc tính này như sau
[MyCustomValidator("Name", "Job")]
[MyCustomValidator("Name", "Email")]
[MyCustomValidator("Name", "Job")]
public class Employe {
}
Vấn đề là chỉ một lần xác thực là được hoàn thiện. Làm thế nào tôi có thể thực hiện tất cả các xác nhận hợp lệ (bằng cách sử dụng asp.net mvc 2)?