How can I set a RegularExpression data annotation's regular expression argument at runtime?

前端 未结 4 1448
长发绾君心
长发绾君心 2020-12-15 06:08

We manage several ASP.NET MVC client web sites, which all use a data annotation like the following to validate customer email addresses (I haven\'t included the regex here,

4条回答
  •  一整个雨季
    2020-12-15 07:00

    Why not just write you own ValidationAttribute?

    http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.validationattribute.aspx

    Then you can configure that thing to pull the regex from a registry setting... config file... database... etc... etc..

    How to: Customize Data Field Validation in the Data Model Using Custom

提交回复
热议问题