标签: asp.net-mvc data-annotations
我有一个字段,我想将System.ComponentModel.DataAnnotations.RangeAttribute应用于
System.ComponentModel.DataAnnotations.RangeAttribute
[Range(0, Int32.MaxValue)]
但我希望这个字段是一个字符串,因为我希望它能有另一个值,那就是“无限制”。是否有一些属性或属性组合我可以用来说“允许任何正整数或字符串”无限制“?
谢谢,
萨钦
。
答案 0 :(得分:1)
尝试使用此问题中的正则表达式: RegEx that matches positive numbers
希望有所帮助。感谢。