views:

68

answers:

2

DataAnnotations: Range, required... got it.

But just checking value==5 or value==bool?

+2  A: 

There isn't one included in .NET, although you can create your own by implementing the ValidationAttribute abstract class. All you have to do is override the IsValid method.

Yuriy Faktorovich
Alright, figures. I know how to do that.
Martin
+1  A: 

Also, if you want to see a sample of how to implement a custom ValidationAttribute, there's are a couple of them in ASP.NET MVC 2.

If you install ASP.NET MVC 2 RC the new default project has two sample attributes that you can look at in ~/Models/AccountModels.cs.

Eilon
Thanks, I know how to do that.
Martin