Working with validation rules in the Database painter

This section describes the ways you can manipulate validation rules in the Database painter. You can create and modify validation rules from the Validation Rule view. This view replaces the Object Details view in the Database painter when you create a new validation rule or select Properties from the pop-up menu for an existing validation rule.

Figure 21-9: Defining a validation rule in the Database painter

The sample displays the General tab of the Validation Rule view in the Database painter. This view is also known as the Object Details view for a validation rule. The General tab has two text boxes labeled Validation Name and Message. It also has a drop down list for Data Type, which by default is string. The default value for the message field states the the column does not pass the validation test, with the column name passed in a variable expression. There is no default for Validation Name.

What you do in the Database painter

In the Database painter, you can:

StepsTo create a new validation rule

  1. In the Database painter, select Object>Insert>Validation Rule from the menu bar.

    The Validation Rule view displays.

  2. On the General tab, assign a name to the rule, select the datatype of the columns to which it applies, and customize the error message (if desired).

    For information, see “Customizing the error message”.

  3. Click the Definition tab and define the expression for the rule.

    For information, see “Defining the expression”.

You can use this rule with any column of the appropriate datatype in the database.

StepsTo modify a validation rule:

  1. In the Database painter, open the Extended Attributes view.

  2. In the Extended Attributes view, open the list of validation rules.

  3. Right-click the validation rule you want to modify and select Properties from the pop-up menu.

  4. In the Validation Rule view, modify the validation rule as desired.

    For information, see “Defining the expression” and “Customizing the error message”.

StepsTo associate a validation rule with a column in the Database painter:

  1. In the Objects view of the Database painter, right-click the column with which you want to associate a validation rule, select Properties from the pop-up menu, and select the Validation tab.

  2. Select a validation rule from the Validation Rule drop-down list.

    The column now has the selected validation rule associated with it in the extended attribute system tables. Whenever you use this column in a DataWindow object, it will use this validation rule unless you override it in the DataWindow painter.

StepsTo remove a validation rule from a column in the Database painter:

  1. In the Objects view of the Database painter, right-click the column from which you want to remove a validation rule, select Properties from its pop-up menu, and select the Validation tab in the Properties view.

  2. Select (None) from the list in the Validation Rule drop-down list.

    The validation rule is no longer associated with the column.