ObjectValidatorAttribute with TargetRuleSet

Topics: Validation Application Block
Nov 19, 2009 at 10:04 PM

Ive been struggling with using the ObjectValidators with rulesets when using the attributes as per this stackoverflow question

I now see why the ObjectValidator doesnt work, and thats because when defining the validators in a config file, the objectvalidator needs a targetRuleset attribute.

Is there a reason this field isnt exposed in the ObjectValidatorAttribute?

Nov 20, 2009 at 7:24 AM


Actually it is exposed on the ObjectValidatorAttribute. There is a overload of the ObjectValidatorAttribute which accepts a string targetRuleSet. You could do something like this:


    public class MockClass
        public SubClass SubClass { get; set; }

        public MockClass()
            SubClass = new SubClass();

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.