This project is read-only.

Can this engine apply rules to input to produce output - or is it strictly for validation?

Sep 15, 2014 at 3:20 PM

Say that I want to determine the customer service phone # applying to a given user based on rules looking at where the user lives and their age.

Does this engine support this -- or is it strictly intended for validation?
Sep 22, 2014 at 12:11 PM
Sorry, at this stage, Rules engine (perhaps not the best name for the framework) is strictly intended for validation
Mar 18, 2015 at 10:34 AM
You can hack the engine to perform actions for you, if you make a rule for your complex object:

class AddDiscountToUserIfUnderAge : IRule<User>
    #region Implementation of IRule

    public ValidationResult Validate(User value)
        if (value.Age < 18)
            value.Fee = value.Fee*0.5; //50% discount for users under the age of 18
        return ValidationResult.Success;

    public string RuleKind { get { return GetType().Name; } }
And then add the rule as follows:
     For<User>().MustPassRule(new AddDiscountToUserIfUnderAge());
Hope this helps :)