Creating and attaching script validators

Creating a validator

A script validator is one of the types of artifacts in the repository. To add a script validator, go to the Library → Script validators, then click the button located on the right Add script validator.

Figure 1. Adding script validators

Edit window

The edit window in the repository allows changing the content of the validator as well as the returned keys and default error messages. In the Parameters section, all input and output parameters (error keys) resulting from the validator's code should be added. The parameters window can be displayed by clicking the .

More information about the editor itself can be found in Script validators editor.

Figure 2. Script validator edit window

Attaching on the form

Attaching a script validator on the form does not differ from attaching a standard validator. For a specific component in the Properties panel you should select Data quality → Validators → Add validator, and then search for its name. In the Input parameters tab you should choose the appropriate component in the Select component or constant. The switch located in the column Call when empty is responsible for invoking the validator even when the specified field has no value (e.g., when a value is removed from a text field).

Figure 3. Attaching a script validator on the form

Creating the validator's error message

The content of the script validator's error message (the key translation) must be defined in the component/form after attaching the validator. Adding the message content in the script is not an error, but it will not be visible in the component/form edit window. After attaching the validator, both the key and its translation will display the key name defined in the script validator's content:

Figure 4. Translation of the script validator key

You should edit the translation column and enter there the message content that should appear when the validator returns a specific error key.

If you need to use variables in the error message, list those variables in the code as parameters (parameters: [value1, value2 etc.]), and then reference them in the component/form error message as follows: {0} for the first parameter, {1} for the second parameter, {2} for the third, and so on.

Figure 5. Translation of the script validator key populated with variables

Figure 6. Error message content visible on the form

Last updated

Was this helpful?