switching from EnterpriseLibrary.Validation to Microsoft.Practices.EnterpriseLibrary.Validation.Validators to System.ComponentModel.DataAnnotations
I'm moving some code from Microsoft.Practices.EnterpriseLibrary.Validation.Validators to System.ComponentModel.DataAnnotations, and have come across a more complex validator that I am having trouble in changing it to Da开发者_如何学运维taAnnotations, anyone got any pointers on how I can convert this?
[NotNullValidator]
[DomainValidator("M", "F", "A", MessageTemplate = "{0} is not valid for {1}")]
public string Gender { get; set; }
In answer to my own question, you don't have to, and perhaps it's best not to, check out my other question on Passing Validation Exceptions via WCF and Rest
I think you will need to write a custom validation extending System.ComponentModel.DataAnnotations.ValidationAttribute
class.
More details can be found on the following question: Custom validation with Data annotations
精彩评论