A validation rule is a boolean expression. PowerBuilder applies the boolean expression to an entered value. If the expression returns “true”, the value is accepted. Otherwise, the value is not accepted and an ItemError event is triggered.
You can use any valid DataWindow expression in validation rules.
Validation rules can include most DataWindow expression functions. A DataWindow object that will be used in PowerBuilder can also include user-defined functions. DataWindow expression functions are displayed in the Functions list and can be pasted into the definition.
For information about these functions, see the DataWindow Reference.
Use the notation @placeholder (where placeholder is any group of characters) to indicate the current column in the rule. When you define a validation rule in the Database painter, PowerBuilder stores it in the extended attribute system tables with the placeholder name. At runtime, PowerBuilder substitutes the value of the column for placeholder.
The @col can be easily used as the placeholder. A button in the Paste area is labeled with @col. You can click the button to paste the @col into the validation rule.
For example, to make sure that both Age and Salary are greater than zero using a single validation rule, define the validation rule as follows:
@col > 0
Then associate the validation rule with both the Age and Salary columns. At runtime, PowerBuilder substitutes the appropriate values for the column data when the rule is applied.