You might be able to use reflection to modify the validator properties that you are interested in. But that is really messy and Kludgy.
What if you simply replaced the message text on the validation results after validation?
The message in the configuration file could be a place holder (e.g. NAME_INVALID_LENGTH) and you could replace that with your actual text.
var cfgSrc = new FileConfigurationSource("Validations.xml");
var factory = ConfigurationValidatorFactory.FromConfigurationSource(cfgSrc);
Validator val = factory.CreateValidator<MyObj>();
MyObj myObj = new MyObj();
myObj.Name = "Swiper McFoxy";
ValidationResults results = new ValidationResults();
foreach (ValidationResult result in val.Validate(myObj))
{
results.AddResult(
new ValidationResult(
GetMessage<MyObj>(result.Message, new CultureInfo("en")),
result.Target,
result.Key,
result.Tag,
result.Validator,
result.NestedValidationResults));
}
Update
OK, if you need the template text you can investigate poking around via reflection but that still looks really messy.
Given your requirements (configuration file, maintain templates) what I would probably do would be to create multiple configuration files each with the template text you want.
That's a bit of a maintenance nightmare so I would refine that idea to:
Create my configuration file Validations.xml
and instead of putting my templated text in I would use a unique placeholder for each message (e.g. NAME_INVALID_LENGTH but even more unique-ish).
Then I would write a small piece of code/tool that would, for every locale you are supporting, replace the unique placeholder with the locale specific templated text. And copy the resultant file to a locale specific folder under the OutDir (e.g. bin\debug\en-US\Validations.xml). This is similar to how .NET deploys satellite assemblies so it is not that far a stretch.
Run the tool above as a post-build step. The tool can flag placeholders that it can't find so that it gets reported during the build. This should help keep the placeholders and the template text in sync.
Modify your code to use the locale specific configuration file:
CultureInfo culture = new CultureInfo("en-us");
var cfgSrc = new FileConfigurationSource(culture.Name + @"\Validations.xml");
var factory = ConfigurationValidatorFactory.FromConfigurationSource(cfgSrc);
Validator val = factory.CreateValidator<MyObj>();
You can abstract the culture specific code behind a helper method so that it's easier to read and maintain. e.g. GetValidationConfigurationSource(culture)
.