You are here: Offline capability > Validate rule support in offline mode > Offline validation API

Offline validation API

The offline validation API consists of a JavaScript method that allows you to run a validate rule in offline-enabled applications by using a Run script action or a custom JavaScript function. Validate rules that are referenced by a flow action are packaged automatically. To package other validate rules, you must add their definition to the pyValidateWhitelistForOffline rule. Remember that a validation rule can also call any number of function rules. These function rules that are part of the validation rule are also packaged automatically.

The following JavaScript method is available for the pega.offline object:

Method

Description

runValidate( validateName,
className )

A synchronous method that runs a validate rule in the offline mode with the specified name and class. It returns a Boolean value specifying whether the validation was successful (true) or not (false). The method also adds messages to properties for which the validation rule failed.

The method has the following parameters:

    validateName Required. Specifies the name of the validate rule to run.
    className Required. Specifies the name of the class that the validate rule belongs to.

Example

The following sample JavaScript code allows you to run a validate rule called pzValidateMeetingTime, which belongs to the PEGA-MANAGEMENT-MEETING class.

if ( !pega.offline.runValidate( "pzValidateMeetingTime",
                                 "PEGA-MANAGEMENT-MEETING" ) ) {
   console.log("Meeting cannot be set up in the past");
}