Executing form-level validation rules

Form-level validation rules can be defined for each field with form specification attributes such as NOT NULL, REQUIRED and INCLUDE. These attributes are part of the business rules of the application and must be checked before saving data into the database.

Implicit validation rule checking

The DIALOG instruction automatically executes form-level validation rules in the following cases:

Automatic validation occurs when the focus leaves a sub-dialog of the DIALOG instruction.

Performing validation rules explicitly

The DIALOG instruction can be used as in singular interactive instructions, with the typical OK / Cancel buttons (i.e. accept / cancel actions) to finish the instruction. This lets the user input or modify one record at a time, and program flow must reenter theDIALOG instruction to edit or create another record. To implement this, you can use the default behavior of the DIALOG instruction, and have it execute the form-level validation rules automatically when focus is lost for a sub-dialog or when leaving the dialog with ACCEPT DIALOG (raised by the OK button). However, you may want to stay in theDIALOG instruction and let the user input / modify multiple records. In this case, you need a way to execute the form-level validation rules defined for each field, before saving the data to the database. Form-level validation rules are defined by the NOT NULL , REQUIRED and INCLUDE attributes.

To validate a subset of fields controlled by the DIALOG instruction, use the ui.Dialog.validate("field-list") method, as shown in this example:
   ON ACTION save 
      IF DIALOG.validate("cust.*") < 0 THEN
        CONTINUE DIALOG
      END IF
      CALL customer_save()

This method automatically displays an error message and registers the next field in case of error. It is mandatory to execute a CONTINUE DIALOG instruction if the function returns an error.