Understanding validation rules

Validation rules are criteria that a DataWindow object uses to validate data entered into a column by users. They are specific to PocketBuilder and therefore not enforced by the DBMS.

Validation rules assigned in the Database painter are used by default when you place columns in a DataWindow object. You can override the default rules in the DataWindow painter.

A validation rule is an expression that evaluates to either TRUE or FALSE. If the expression evaluates to TRUE for an entry into a column, PocketBuilder accepts the entry. If the expression evaluates to FALSE, the entry is not accepted and the ItemError event is triggered. By default, PocketBuilder displays a message box to the user.

Figure 21-8: Message box triggered by validation rule violation

Shown is a message box triggered when a validation rule fails. The message in the message box indicates that "Item Z does not pass the validation test."

You can customize the message displayed when a value is rejected. You can also code an ItemError script to cause different processing to happen.

For more information, see the chapter on using DataWindow objects in the Resource Guide.

NoteAt runtime In scripts, you can use the GetValidate function to obtain the validation rule for a column and the SetValidate function to change the validation rule for a column.

For information about the GetValidate and SetValidate functions, see the DataWindow Reference in the online Help.