Does DataType DataAnnotation Check the Expression?
- by Jason
I am currently using DataAnnotations within my ASP.NET MVC website to ensure data is properly validated. One question I wanted to verify (I think I know the answer, but I can't find verification online) - does the DataType DataAnnotation perform regular expression checks to ensure that you have received a valid e-mail/phone/currency/etc?
[Required(ErrorMessage = "Price required")]
[DataType(DataType.Currency, ErrorMessage = "Not a valid price")]
[Range(0, double.MaxValue, ErrorMessage = "Price must be greater than 0.")]
public decimal Price { get; set; }
I believe the answer is no (meaning I have to provide my own, custom, RegularExpressionAttribute), but I wanted to double check before I do that for various field types.