Triggering Validation Execution
Each entity row tracks whether or not its data is valid. When a user modifies a persistent attribute of an existing entity row or creates a new entity row, the entity is marked as invalid, and any validation that you have implemented is evaluated again before the entity is again considered valid. In validation rules, you can specify when this validation is executed as follows:
Validation Level: In an entity validation rule, you can specify whether validation should be performed at the entity-level (the default) or at the transaction level. If you specify that it should be performed at the transaction level, it will be carried out after all entity-level validation. For this reason you should use this option where you want to ensure that a specific piece of validation is performed at the end of the process.
Conditional Execution: You can enter a Boolean condition using a Groovy expression to define conditional validation execution. When the condition evaluates to true, the rule is executed. You have the option to test your expression to see if it is valid.
Triggering Attributes: By default a validator fires on an attribute whenever the entity as a whole is dirty. However, in an entity validation rule, you can choose to trigger validation only when certain attributes change (when one of the triggering attributes is dirty).
Validation always occurs before changes are posted to the database. If you must code validation that depends on seeing posted changes, override the beforeCommit() method in the object’s Java file.