How reference the max length in the Length Message?

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
Post Reply
CodeSlinger
Posts: 31
Joined: Mon 04 May 2015 18:49

How reference the max length in the Length Message?

Post by CodeSlinger » Mon 11 May 2015 19:30

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

Shalex
Site Admin
Posts: 8247
Joined: Thu 14 Aug 2008 12:44

Re: How reference the max length in the Length Message?

Post by Shalex » Thu 14 May 2015 13:56

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.

CodeSlinger
Posts: 31
Joined: Mon 04 May 2015 18:49

Re: How reference the max length in the Length Message?

Post by CodeSlinger » Fri 05 Jun 2015 15:32

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.

Shalex
Site Admin
Posts: 8247
Joined: Thu 14 Aug 2008 12:44

Re: How reference the max length in the Length Message?

Post by Shalex » Tue 09 Jun 2015 12:31


CodeSlinger
Posts: 31
Joined: Mon 04 May 2015 18:49

Re: How reference the max length in the Length Message?

Post by CodeSlinger » Mon 29 Jun 2015 19:43

Done.

Post Reply