我收到的错误是Model.IsValid == false。 这是其中一个有错误的酒店:
// 属性 [RegularExpression( @ ^ [0-9] * $,ErrorMessage = 无效数字)] public 列表< string>数字{获取; set ; } // 构造函数 public ClassName() { Numbers = new List< string>(); }有人可以解释一下为什么吗?我是否需要验证列表的每个元素?如何实现呢? 我尝试过: 我试图调试问题并搜索谷歌但没有找到任何有用的东西。
解决方案,ErrorMessage = 无效数字)] public 列表< string> Numbers { get ; set ;} // 构造函数 public ClassName() { Numbers = new 列表< string>(); }
有人可以解释一下为什么吗?我需要验证清单中的每个元素吗?如何实现它? 我尝试了什么: 我试图调试问题并搜索谷歌但没有找到任何有用的东西。
希望这个工作.. c# - 对我的ViewModel列表中的每个项目进行数据验证 - Stack Overflow [ ^
Hi, I am getting an errors that Model.IsValid == false. Here is one of the property with an error:
// Property [RegularExpression(@"^[0-9]*$", ErrorMessage = "Invalid number")] public List<string> Numbers { get; set; } //Constructor public ClassName() { Numbers = new List<string>(); }Can someone explain me why? Do I need to validate each element of the List? How to achieve it? What I have tried: I tried to debug the problem and searched google but didn't find anything usefully.
解决方案 ", ErrorMessage = "Invalid number")] public List<string> Numbers { get; set; } //Constructor public ClassName() { Numbers = new List<string>(); }Can someone explain me why? Do I need to validate each element of the List? How to achieve it? What I have tried: I tried to debug the problem and searched google but didn't find anything usefully.
Hope this works.. c# - Data validation for every item in a list of my ViewModel - Stack Overflow[^]更多推荐
列表的验证属性< string>
发布评论