[英]Data Annotation/Validation and dynamic values
If some of my models have dynamic validation conditions (ie the string length can be minimum of 8 or 12 depending on a database value or some other dynamic value) is it impossible to use data annotation for validation? 如果我的某些模型具有动态验证条件(即,字符串长度可以最小为8或12,具体取决于数据库值或其他动态值),是否无法使用数据注释进行验证?
From what I understand, the values of any parameter (example StringLength min/max value) have to be truly static. 据我了解,任何参数的值(例如StringLength最小值/最大值)必须是真正静态的。 Are there alternatives for applications that have dynamic validation values?
具有动态验证值的应用程序是否可以替代?
Your pretty much stuck with writing your own custom validationattribute: 您几乎坚持编写自己的自定义验证属性:
http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.validationattribute.aspx http://msdn.microsoft.com/zh-CN/library/system.componentmodel.dataannotations.validationattribute.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.