Page 1 of 1
How reference the max length in the Length Message?
Posted: Mon 11 May 2015 19:30
by CodeSlinger
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?
Posted: Thu 14 May 2015 13:56
by Shalex
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.
Re: How reference the max length in the Length Message?
Posted: Fri 05 Jun 2015 15:32
by CodeSlinger
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?
Posted: Tue 09 Jun 2015 12:31
by Shalex
Re: How reference the max length in the Length Message?
Posted: Mon 29 Jun 2015 19:43
by CodeSlinger
Done.