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.

Edit window
The edit window in the repository allows changing the validator's content as well as the returned keys and default error messages. In the Parameters section you should add all the inputs and outputs (error keys) that result from the validator's code. The parameters window can be displayed by clicking the
.
More information about the editor itself can be found in Script validator editor.

Attaching on the form
Attaching a script validator on a 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, then search for its name. In the Input parameters tab you should choose the appropriate component in the Choose component or constantfield. The switch located in the Call when empty column is responsible for invoking the validator even when there is no value in the specified field (e.g., when a value is removed from a text field).

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 the validator is attached. 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:

You should edit the translation column and enter the message content that should appear when the validator returns a specific error key.
If it is necessary 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.


Last updated
Was this helpful?
