Purpose:
Validation rules are used in almost all the applications which includes a database to make sure only valid data is committed to the database. You can define validations on your business service layer or directly on user interface.
As per fusion guide there are three types of validation rules that can be used on entity objects:
- Attribute-level validation.
- Entity-level validation.
- Transaction-level validation.
Attribute-level validation:
These validations are applied on attributes. Few examples might be upper and lower limit for salary, OrderDate should not be a date in the past and Length of attribute values.
How to:
- Select the attribute on EO.
- Edit Attribute.
- Validation.
- Define the check you want to perform under Rule Definition.
- Use Failure Handling to provide info to user.
*Any conditions needed to perform/skip validation can be added in Validation Execution.
Entity-level validation:
These are rules whose implementation requires considering two or more entity attributes, or children entity rows, in order to determine the success or failure of the rule. These validations are similar to attribute-level but with a broader scope which can be applied to whole row. One example is EventOrganiser cannot be a participant, collection validator. When entity-level method validation is created, a method will be added to EO's custom java class.
How to:
Transaction-level validation:
TL validation will be handy when you want to defer validation execution to transaction level or when you want to validate multiple rows data. This validation will be performed after all entity-level validations are performed. An example might be where only one eventOrganiser is allowed for each event. Creation is same as in Entity level except that "Defer Execution to Transaction level" is selected in Validation Execution tab. This method will be added to EO's java class.
Happy Coding :)
How to:
- Go to EO.xml
- Business Rules
- Add Entity Validator.
- Define rule by selecting available rule types from Rule Definition.
- Validation Execution with "Execute at entity level" and select attributes to which the rule should be applied.
- Use Failure Handling to provide info to user.
Transaction-level validation:
TL validation will be handy when you want to defer validation execution to transaction level or when you want to validate multiple rows data. This validation will be performed after all entity-level validations are performed. An example might be where only one eventOrganiser is allowed for each event. Creation is same as in Entity level except that "Defer Execution to Transaction level" is selected in Validation Execution tab. This method will be added to EO's java class.
Happy Coding :)
Comments
Post a Comment