IDataErrorInfo - 是否存在集合不为空的验证属性?
我不知道我是否找不到它或者它是否不存在,但是是否有任何验证属性可以检查集合是否为空/空?
如果没有,是否有关于如何创建我自己的验证属性的好资源?
I don't know if I just can't find it or if it does not exist, but is there any validation attribute which checks if a collection is null/empty or not?
If not, is there any good resource out there on how to create my own validation attribute?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您按照 default.kramer 建议使用 DataAnnotations 时,您可以创建将 CustomValidation 属性和 ValidationMethod 添加到集合属性和类中。请参阅下面的示例。
ValidationMethod 的重要部分是它是静态的,您必须将要验证的对象和 ValidationContext 添加到静态方法。
}
When you use DataAnnotations as per default.kramer suggested you can create add a CustomValidation attribute and ValidationMethod to you collection property and class. See example below.
The important part of the ValidationMethod is that it is Static and you have to add the object that you're validating and the ValidationContext to the static method.
}