If I had error messages in the validation attribute, for example:
- Name required
- Last name required
and then the validation attribute as follows:
[Required(ErrorMessageResourceName = "Error_FirstNameRequired", ErrorMessageResourceType = typeof(Strings)] public string FirstName {get;set;}
I do not want a translation to be made for each instance of this. Is there a way to combine resource strings in formatting, for example:
[Required(ErrorMessage = string.Format("{0} {1}", Strings.Label_FirstName, Strings.Error_IsRequired))] public string FirstName {get;set;}
Of course, this does not work, because it must be a compile-time constant. But is it possible to achieve this so that I can build localized strings and reuse those that already exist? I was thinking of creating custom attributes that allow you to set additional properties and override the default message displayed, but it will be too much refactoring and some kind of kludgy imo.
Any ideas?
source share