Data validation can be applied to any form component. The data validation of a field, are configured on the component itself, and can be found by viewing the Validation tab within the components settings. The data validation of a field, are configured on the component itself, and can be found by viewing the Validation tab within the components settings.
The following options are available:
- Required: If checked, the field will be required to have a value upon submission.
- Minimum length: The minimum number of characters required to be entered for this field.
- Regular Expression Pattern: The regular expression pattern test that the field value must pass before the form can be submitted. See regex101.com for help with writing regex expressions.
Advanced data validation
In addition, input variable is set to the value that has been entered in the field. The component variable is set to the definition of the field.
You can also reference other resources and properties for validation. For example, if there is a user resource with a password field, you can use its value with user.password
Advanced data validation is mainly required when you want to validate a combination of multiple fields and/or values. Here are few use cases:
- Consistency checks:
- The value of 1 input should never be higher/lower of another
- Control sum at the end entered by the user (e.g. nested forms to add expenses)
- Show a follow-up questions when a specific word occurs
- Check if a word occurs multiple times
- Check for minimum of x characters and y digits
- Conditional based on the validation of multiple fields
- If a = 1 AND b = 2, then
- Multiple choice for an app reference:
- Error if value = item a OR item = b