Form-level validation rules

Form-level validation rules can be defined for each field controlled by a dialog.

Form-level validation can be specified at the form field level with 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

An INPUT or INPUT ARRAY block automatically executes form-level validation rules in the following cases:

Performing validation rules explicitly

Singular input dialogs (INPUT / INPUT ARRAY) create default accept / cancel actions. The form-level validation rules are typically performed when the implicit accept action is triggered.

The DIALOG procedural instruction can be used as in singular interactive instructions, with the typical OK / Cancel buttons (i.e. accept / cancel actions) to finish the instruction. The accept/cancel action handlers would respectively execute the ACCEPT DIALOG and EXIT DIALOG instructions. This solution lets the user input or modify one record at a time, and the program flow must reenter theDIALOG instruction to edit or create another record. Alternatively, theDIALOG instruction can let the user input / modify multiple records without leaving the dialog. 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.

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.

Within singular input dialogs, form-level validation rules can also be explicitly performed with the ACCEPT INPUT instruction, or with the DIALOG.validate("*") API call, followed by a CONTINUE INPUT in case of error.