Rules and Scope values

Mar 18, 2015 at 5:22 AM
I have a set of rules say 1 - 50 that I wish to apply By state.

If FL use rule 1, 2, 3, and 5
If TN use rule 1, 3, and 4
If SC use rule 1, 2, and 5

etc.

How can I accomplish this? Is it possible to give rules scope values and then validate the rules based on scope?

If so how is that coded?

Thanks you for your prompt reply
Angel L. Bermudez, Jr.
Coordinator
Mar 19, 2015 at 6:55 AM
Edited Mar 19, 2015 at 6:55 AM
Hi,

I am not entirely sure I am understanding the question... the rules apply to State or something else? I'll assume the later and therefore, you probably would use conditional construct to achieve this:
Engine engine = new Engine();
            engine.For<Address>()
                .If(a => a.State == "FL")
                    .Setup(ph => ph.MyOtherProperty)
                        .MustPassRule(new Rule1())
                        .MustPassRule(new Rule2())
                        .MustPassRule(new Rule3())
                        .MustPassRule(new Rule5())
                .EndIf()
                .If(a => a.State == "TN")
                    .Setup(ph => ph.MyOtherProperty)
                        .MustPassRule(new Rule1())
                        .MustPassRule(new Rule3())
                        .MustPassRule(new Rule4())
                .EndIf()