Property Validation with Policy Injection

Topics: Policy Injection Application Block, Validation Application Block
Jun 6, 2007 at 11:01 PM

I like to have a property validation called from Policy Injection. So everitime the property is set the Policy Injection should validate the value.

First of all I have a small Interfaces with the property and also a interface methode.
interface ITestObject
RangeValidator(50, RangeBoundaryType.Exclusive, 100, RangeBoundaryType.Inclusive, MessageTemplate = "Value Range error")
int Value

List<TestDataContract> FindData(TestDataContract request);

The configucation looks
<add name="Policy">
<add type="Microsoft.Practices.EnterpriseLibrary.PolicyInjection.MatchingRules.TypeMatchingRule, Microsoft.Practices.EnterpriseLibrary.PolicyInjection, Version=, Culture=neutral, PublicKeyToken=5a467f8f18a3a234"
name="Type Matching Rule">
<add match="HowTo.ITestObject" ignoreCase="false" />
<add ruleSet="" specificationSource="Both" type="Microsoft.Practices.EnterpriseLibrary.PolicyInjection.CallHandlers.ValidationCallHandler, Microsoft.Practices.EnterpriseLibrary.PolicyInjection.CallHandlers, Version=, Culture=neutral, PublicKeyToken=5a467f8f18a3a234"
name="Validation Handler" />

And the program looks
ITestObject woObj1 = PolicyInjection.Wrap<ITestObject>(obj1);
woObj1.Value = 500;
with this assignment nothing is happen (but I expect a exception)
woObj1.FindData(new TestDataContract("123456", "12"));
this FindDate will throw a exception (this is what I expact)
ValidationResults vr2 = Validation.ValidateFromAttributes<ITestObject>(woObj1);
The Valudation Result is correct filled

Should this work? I make a mistake or is this a bug?