Are there any class-baked validations in C #?

I want to do simple things in my web application like Checker.Email (string) that return true or false after some regex or whatever has been executed. But I don't want to do it all myself if it already exists ...

+2


source to share


3 answers


If you are using ASP.NET, I would look at RegularExpressionValidator, which is one of the standard elements of the .Net Framework. Then grab the email regex from www.regexlib.com.



+2


source


If you are using web forms, there are several ValidationControls that you can place on the side, and many third party controls that use the same system (Inherit BaseValidator or CustomValidator).



+1


source


You can use data annotations. There is a small tutorial on asp.net/mvc . There is also a DataType attribute that will validate the email for you. If this method is used, Steve Sanderson's xVal which really makes client / server side validation pretty straightforward.

0


source







All Articles