Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between a validation rule and a business rule?

What is the difference between a validation rule and a business rule ?

As per my understanding, 'if the state of the business object/objects is not as expected, then throw an error message' is a validation rule, and 'when the state of the business object/objects is or is not equal to something, then change the state of some business object/objects [or take some action/event but not just throw an error]' is a business rule.

Validation can be UI validations - validate values of UI fields or application validations - validate business object states.

I am not sure whether my understanding above is correct. In my project, we have a validation framework, where a simple validate call takes business objects to validate against something and an error collector that collect all errors. The errors are displayed on the screen afterwords.

In addition to that, we have rules that falls in second category as described above i.e check the business object/objects state and take some action such as change the state of another business object. I am trying to find out the strategy to implement such rules either using some framework [not a validation framework] or a rule engine.

Can you please help me understanding the distinction between the above 2 kind of rules and if there are any implementation strategies/ recommendations, it would be helpful.

like image 685
Snake Avatar asked Jul 08 '11 22:07

Snake


People also ask

What is a validation business rule?

A Validation Rule is a specific type of Business Rule that is used to perform validation of information captured on PPO by users. It therefore prevents the update from taking place based on the specified conditions.

What is a validation rule?

A validation rule is one way to restrict input in a table field or a control (such as a text box) on a form. Validation text lets you provide a message to help users who input data that is not valid.

What is the association between a business rule and a validation table?

What is the association between a business rule and a validation table? 12. You can use a validation table to enforce a constraint that a business rule imposes on a given field's range of values.

What does business rule mean?

A business rule defines or constrains some aspect of business and always resolves to either true or false. Business rules are intended to assert business structure or to control or influence the behavior of the business. Business rules describe the operations, definitions and constraints that apply to an organization.


2 Answers

A validation is a check that the value entered is legitimate for the context of its field (from technical perspective), for example: is 5 as a numeric value acceptable for Age(v.s. -5)?, while -5 is acceptable as Temperature for example.

The business rule is more of a business perspective. It is a check that the values (that passed the validation) are acceptable by the policies and procedures of the business. E.g. the person who is allowed to register has to be a resident, and 18 years old or more..etc. The business rule might check one (or more) field(s) value(s), and might consult data stored in a database and/or do some calculation(s) to ensure that the value(s) pass the business rules.

So, for the example posted above by hanna, the value 15 should pass the field validation (as it is a valid value for Age), but it will not pass the business rule check that the married person's age must be >15.

like image 148
Muhammad Avatar answered Nov 03 '22 02:11

Muhammad


In short; a validation rule determines basic validity; "is this a valid email address?" A business rule determines what to do with the valid data; "can I set the user's confirmation email to the submitted value?" Business rules can migrate into validation logic; but typically, validation is not done by the business rule engine.

like image 37
Paul Sonier Avatar answered Nov 03 '22 01:11

Paul Sonier