Writing a new post because I need more formatting than comments.
See ValidationAttribute , the base class of validation attributes.
If a validation error occurs, an error message will be generated by the method:
public virtual string FormatErrorMessage(string name) { return string.Format(CultureInfo.CurrentCulture, this.ErrorMessageString, new object[] { name }); }
Next, view the ErrorMessageString property:
protected string ErrorMessageString { get { if (this._resourceModeAccessorIncomplete) { throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, DataAnnotationsResources.ValidationAttribute_NeedBothResourceTypeAndResourceName, new object[0])); } return this.ResourceAccessor(); } }
The ResourceAccessor property can be set from:
ValidationAttribute..ctor(Func<String>) ValidationAttribute.set_ErrorMessage(String) : Void ValidationAttribute.SetResourceAccessorByPropertyLookup() : Void
Firstly, it is used by dervided fonts to format messages, secondly, the case when we install the ErrorMessage error message , and thirdly, when using resource strings. Depending on your situation, you can use ErrorMessageResourceName .
Elsewhere, consider derivative constructors, for our example: Range attribute:
private RangeAttribute() : base((Func<string>) (() => DataAnnotationsResources.RangeAttribute_ValidationError)) { }
Here RangeAttribute_ValidationError is loaded from the resource:
internal static string RangeAttribute_ValidationError { get { return ResourceManager.GetString("RangeAttribute_ValidationError", resourceCulture); } }
So, you can create a resource file for different default tan settings and overwrite messages there:
http://www.codeproject.com/KB/aspnet/SatelliteAssemblies.aspx
http://msdn.microsoft.com/en-us/library/aa645513(VS.71).aspx