Offline validation API

The offline validation API consists of a JavaScript method that runs a validate rule in offline-enabled mobile apps by using a Run script action or a custom JavaScript function.

Offline validation is possible with the runValidate JavaScript method that is available for the pega.offline object. You can run the following rules with this method:
  • Validate rules that are referenced in flow actions
  • Validate rules that you add to the list of offline-supported validate rules

Purpose

Runs a validate rule in offline mode with the specified name and class.

Signature

runValidate( validateName, className )

Returns

Returns a Boolean value that specifies whether the validation was successful (true) or not (false). The method also adds messages to properties for which the validation rule failed.

Parameters

Name Description Type Required
validateName Specifies the name of the validate rule to run. String
className Specifies the name of the class that the validate rule belongs to. String

In the following example, JavaScript code runs a pzValidateMeetingTime validate rule of the PEGA-MANAGEMENT-MEETING class.

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