I am using datannotations and the server/client side validation stuff in ASP.NET MVC 2. Everything works fine if a class has properties such as:
[Required(ErrorMessage = "whatever")]
String blah;
but I have no idea how to make t开发者_运维百科his:
[Range(13134, 42352345, ErrorMessage = "outside of range")]
List<int> blah;
where I want the int to be in that range.
I think you will have to write a custom validator to do this. This article by Scott Gu is useful for explaining writing custom validators
This msdn article may be more appropriate as it specifically discusses custom range validation
精彩评论