数据标注/验证和动态值 [英] Data Annotation/Validation and dynamic values

查看:129
本文介绍了数据标注/验证和动态值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我的一些型号的具有动态验证条件(即字符串长度可以取决于一个数据库值或一些其它动态值8或12的最小值)是它不可能用数据注解为验证?

If some of my models have dynamic validation conditions (i.e. 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?

据我了解,任何参数的值(例如StringLength最小值/最大值)必须是真正静态的。是否有应用具有动态验证值的替代品?

From what I understand, the values of any parameter (example StringLength min/max value) have to be truly static. Are there alternatives for applications that have dynamic validation values?

推荐答案

您pretty多坚持写自己的自定义validationattribute:

Your pretty much stuck with writing your own custom validationattribute:

<一个href=\"http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.validationattribute.aspx\" rel=\"nofollow\">http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.validationattribute.aspx

这篇关于数据标注/验证和动态值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆