How reference the max length in the Length Message?
-
- Posts: 31
- Joined: Mon 04 May 2015 18:49
How reference the max length in the Length Message?
I'm able to edit the DbContext template, and set Validation Framework to "Data Annotations" and then set a "Length Message". Is there anyway to reference the max length in the Length Message so I can say something like "Maximum Length of {0} characters was exceeded." and fill in the maximum length? Thx
Re: How reference the max length in the Length Message?
If the length limitation is the same (e.g.: 50) for all string properties in your model, you can set Length Message to "Maximum Length of 50 characters was exceeded." via properties of the template.
If the length limitations are different, you should create your own Validation.tmpl (instead of the predefined one). For this, open the DbContext template, set focus to <#@ include file="Validation.tmpl" #>, press F12 to open a predefined Validation.tmpl. Create your own Validation.tmpl in the model and copy content of the predefined Validation.tmpl in it. As a result, now your Validation.tmpl is used for code generation. You can edit it and define any message you want.
If the length limitations are different, you should create your own Validation.tmpl (instead of the predefined one). For this, open the DbContext template, set focus to <#@ include file="Validation.tmpl" #>, press F12 to open a predefined Validation.tmpl. Create your own Validation.tmpl in the model and copy content of the predefined Validation.tmpl in it. As a result, now your Validation.tmpl is used for code generation. You can edit it and define any message you want.
-
- Posts: 31
- Joined: Mon 04 May 2015 18:49
Re: How reference the max length in the Length Message?
Understood. Nice for a future release would be some standard template support for messages where the attributes such as max length could be substituted into {0} or some such selector. Thx.
Re: How reference the max length in the Length Message?
Please submit your suggestion via http://devart.uservoice.com/forums/3867 ... -developer.
-
- Posts: 31
- Joined: Mon 04 May 2015 18:49