Input Validation vs.Business Rules Validation

time to read 2 min | 335 words

I am probably going against conventional wisdom here, but I wanted to talk about the difference between input validation and business rules validation.

Input Validation for me is about validating the user input. Some people call "Name must not be empty" a business rule, I think about it as input validation. Business Rules validation is more complex, because a business rule for me is not "Name must not be empty", it is a definition of a state in the system that requires an action. Here is a definition of a business rule:

An order should be payed within 30 days, this duration can be extended, to a maximum of three times.

In this case, invalid business rule is something that exists in the system by definition, and require some sort of an action. Flagging the user, sending a PayUp(tm) letter, etc. It is also usually something that involves more than a single object and its properties. "Paid order" means that there is an accepted transaction for this order within the specified range, and extending the duration of acceptable payment is another object entirely.

Input validation can be as simple as validating required fields or as complex as: "You need to input phone number OR email, if you enter ungency you must put reason description OR reason code". Business rules validation is beyond that, it is validating that the total sum of the order is less than the allowed credit for this acount.

I tend to use different UI for the different validation schems as well. Input validation is something that needs to be presented near or at the input itself. Business rules validation is something that is generally a different screen all together, and is distinctly different that the input itself.