Is there any baked in validation classes in C#?
I want to do simple things anyone in my web app like Checker.Email(string) which would return true or false after doing some regex or something. But I don't want to make this whole thi开发者_运维百科ng myself if one already exists...
If you are using ASP.NET then I'd look at the RegularExpressionValidator that's one of the standard .Net Framework controls. Then grab an email regex from www.regexlib.com.
If you're using webforms, there are several ValidationControls you can place on the from, and a slew of third-party controls that use the same system (Inherit BaseValidator or CustomValidator).
You can use Data Annotations. There is a little tutorial at asp.net/mvc. There's also a DataType attribute that will validate an email for you. If use this method, there's xVal by Steve Sanderson which really makes client/server side validation pretty simple.
精彩评论