Jun 15, 2009 at 7:44 AM
Edited Jun 15, 2009 at 7:48 AM
This should work for those defined in configuration files.
IConfigurationSource configSource = new SystemConfigurationSource();
ValidationSettings settings = (ValidationSettings)configSource.GetSection("validation");
ValidatedTypeReference typeReference = settings.Types.Get(typeof(Foo).FullName);
foreach (ValidationRulesetData ruleSet in typeReference.Rulesets)
var fields = ruleSet.Fields.ToList();
foreach (var field in fields)
// access field.Validators property.
For the ones which are defined as attributes, I haven't tried it yet but that would require a lot of reflection I think. You could examine the EntLib source code on how it creates validators from attributes (ValidationFactory.CreateValidatorFromAttributes).
Global Technology & Solutions