Search code examples
c#validationnxbre

What would you use for a business validation layer?


In my project I need to create a business object validation layer that will take my object and run it against a set of rules and return either pass or fail and it's list of failure reasons. I know there are quite a few options out there for accomplishing this.

From Microsoft:

Open Source:

Has anyone had any particularly great successes or failures with any of these technologies (or any that I didn't list) or any opinions on what they feel is best suited for business rules validation.

Edit: I'm not just asking about generic validations string length < 200, zip code is 5 digits or 5+4 but assume that the rules engine would actually be leveraged.


Solution

  • The code-versus-rules-engine decision is a matter of trade-offs, IMHO. A few examples are:

    Advantages of code

    • Potentially higher performance.
    • Uses developers' existing skills.
    • No need for separate tools, run-time engines, etc.

    Advantages of rule engine

    (Features vary across the various rule engines.)

    • Rule DSL that is writable (or at least readable) by business users.
    • Effective- and expiration-date properties that allow automatic scheduling of rules.
    • Flexible reporting from rule repository supports improved analysis and auditing of system behavior.
    • Just as data-base engines isolate data content/relationship issues from the rest of the system, rules engines isolate validation and policy from the remainder of the system.