MetaGuru
MetaGuru

Reputation: 43873

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 thing myself if one already exists...

Upvotes: 2

Views: 140

Answers (3)

scottm
scottm

Reputation: 28699

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.

Upvotes: 0

Lazarus
Lazarus

Reputation: 43094

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.

Upvotes: 2

Joel Coehoorn
Joel Coehoorn

Reputation: 416059

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).

Upvotes: 1

Related Questions