I've downloaded the ValidationQuickStarts and checked some examples there and it seems that Rule Set validation example does not work...
After some code review I think that there is a bug related to it in MemberValidationManager.
protected bool CheckValidMember(InfoDescriptor infoDescriptor, object memberValue)
{
IList<Rule> rules;
bool ruleFound = infoDescriptor.Rules.TryGetRulesForRuleSet(this.RuleSet, out rules);
if (ruleFound)
{
for (int index = 0; index < rules.Count; index++)
{
Rule propertyRule = infoDescriptor.Rules[index];
ruleFound = true;
ValidationResult validationResult = propertyRule.Validate(this.Target, memberValue, this.Context);
this.errorDictionary.Remove(propertyRule);
if (validationResult != null)
{
this.errorDictionary.Add(propertyRule, validationResult);
}
}
}
return ruleFound;
}
First it tries to find all Rules for given RuleSet:
IList<Rule> rules;
bool ruleFound = infoDescriptor.Rules.TryGetRulesForRuleSet(RuleSet, out rules);
and then if rules are found it operates not on found ones (for specified rule set name), but on all rules in infodesriptor
Rule propertyRule = infoDescriptor.Rules[index];
I guess the code here should use rules found first in this method:
Rule propertyRule = rules[index];
After this change RuleSet example works fine