Set central validation rules

When saving a data record in GAPTEQ, the values of the data fields can be checked using a centrally stored validation rule.

In this article you will read the following content:

Example - simple validation

Store validation rules

1. Example - simple validation

TD_FT_DataLayerValidation_Screenshot_1

The example shows a simple validation rule:
After confirming the “Temperature for goods requiring refrigeration” (german version in screenshot: "Temperatur bei kühlpflichitiger Ware" checkbox, a value in degrees Celsius must be entered in the “Temperature in °C” field. 

If the validation rule “Requirement: Form field temperature must not be empty if checkbox is activated” applies, saving is prevented and a message box with the defined error message is displayed.

TD_FT_DataLayerValidation_Screenshot_3

2. Store validation rules

Note! The advantage of validation in the data layer is that the validation rules are defined in a central location and are therefore valid for all components that use the data layer.

  • Click on “Validation” in the corresponding data layer to open the editor window.

Tip! The programming language in GAPTEQ Custom Expressions is JavaScript.

  • Clicking on “Script skeleton” inserts JavaScript code as the basic framework for the validation. This means that the syntax is predefined and only the condition has to be written and the text for the error message adapted.

TD_FT_DataLayerValidation_Screenshot_2-1

The editor provides all available objects and enables error-free insertion into the code. In addition to the help functions provided in the editor, you can use the full range of JavaScript languages without restriction.

  • A “result.valid = false” indicates that the values are not valid. The defined error message is triggered and the data record is not saved.

Tip! You can find an example of how to set a validation rule in the data layer in the GAPTEQ SAMPLE APP Incoming Goods Inspection in the “tableIncoming Goods Inspection” data layer.