Validation is the process to ensure that data is entered into a field correctly. The value entered for the field is the right data and in the right format.
In Customer Detail Form, you must validate if the email id entered is a valid email id. .
- Must contain '@' and '.' character.
- There must be at least one character before and after '@'.
- There must be at least two characters after '.' (dot).
Common validations done are:
- Are all the mandatory fields filled?
- Is valid date entered?
- Is valid email id entered?
- Is text entered in a numeric field?
Validations can be performed using the User-Defined functions. To know more about User-Defined functions, click here.
A field can have one or more validations based on the requirement, or none.
Create User-Defined function for validation
- Navigate to Functions tab of a node within the Task in the Design Studio.
- Select the User Defined option.
- Click the + icon to add the function.
- Give an intuitive Name and description for the function.
- Select Validation from the Type drop-down.
Only functions with Validation type are listed in Select function from Jiffy drop-down while adding the Validations.
- Click the Save button.
- Click the Edit icon to edit the function.
- Click the + icon and add the variables as per the requirement.
- In the Function definition, write the Python code to check the validation rules.
If validation rules not met return an intuitive error message.
To validate an Email id field, the following Python code is written.
If validation criterion not met, error message ‘Invalid email’ is returned.
You can add the validations for each field in the form.
- Click the Validation icon.
- Click the ADD NEW button to add the validations.
- Select the User-Defined function from the drop-down.
User-Defined functions of type validations created in the HyperApp will be listed in the drop-down.
- Select the Parameter to be passed to the User-Defined Function selected from the drop-down.
All the columns of the selected table with its inline table columns will be listed in the drop-down.
Number of parameters to be passed varies based on number of parameters defined in the User-Defined function. E.g if the function selected has two parameters defined then two placeholders will be displayed.
- To add more validations, Click the + icon.
- Click the Save Button.
Validations are applicable only for Jiffy tables and not for Doc tables.
How Validation Error messages are displayed in the form
Fields in the form are validated as per the business requirement.
If the validation rules set in the user-defined functions are not met for the field, the error messages returned by the functions are displayed under the respective fields on the click of the Save button in the form.
In Customer Detail Form, if Email id is not entered or does not meet the validation rules set in the User-Defined function EmailValidationCheck, the error message 'Invalid Email' returned is displayed under Email field on click of the Save button.