开发者

Validation of List<int> property

开发者 https://www.devze.com 2023-03-08 17:33 出处:网络
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:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号