Does DataType DataAnnotation Check the Expression?

Posted by Jason on Stack Overflow See other posts from Stack Overflow or by Jason
Published on 2010-06-11T18:29:17Z Indexed on 2010/06/11 18:32 UTC
Read the original article Hit count: 282

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.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about validation