Examples of validations
Rules > Examples of validations
E-mail address with a valid format
Every time a user types an invalid e-mail address, a red indication will be shown in a text field where it was typed, and the tooltip "Type a valid e-mail address" will be displayed when hovering over such a field. The application form cannot be saved until the user complies with this validation.
Table: Customer
Field: Customer e-mail address (Text field)
Validation type: E-mail address
Name: Valid customer e-mail address
Valid when: Customer e-mail address matches (.\@.\..+)?
Message to user: Type a valid e-mail address
Phone number with a specific format
Every time a user types a phone number that does not match with the expected format, a red indication will be shown in the text field where it was typed, and the tooltip "The format must be +46-8-111-22-333" will be displayed when hovering over such a field. The application form cannot be saved until the user enters a value according to this pattern.
Table: Customer
Field: Customer phone number (Text field)
Validation type: Phone number
Name: Valid customer phone number
Valid when: Customer phone number matches [+][0-9]{2}-[0-9]-[0-9]{3}-[0-9]{2}-[0-9]{3}
Message to user: The format must be +46-8-111-22-333
Finish date cannot be earlier than Start date
If the user enters a date that is chronologically invalid in comparison with another date, a red indication will be shown, and the tooltip "Finish date must be equal or later than Start date" will be displayed when hovering over such a field. The application form cannot be saved until the user enters a valid date.
Table: Activity
Field: Finish date (Date field)
Validation type: New validation
Name: Finish later than Start
Valid when: not Finish date < Start date
Message to user: Finish date must be equal or later than Start date
Make a field mandatory based on another field (using Is empty function)
If the user ticks the checkbox "Other reason", then a short explanation must be provided in the text field "Describe reason", otherwise (i.e., if checkbox not set), the text field must be left empty. A red indication will be shown and the tooltip "If Other reason was chosen, please describe the reason" will be displayed when hovering over such a field. The application form cannot be saved until the user complies with this.
Table: Survey
Field: Other reason (Checkbox)
Validation type: New validation
Name: Describe reason must be entered if Other reason is checked
Valid when: if Other reason is empty then Describe reason is empty else not Describe reason is empty
Validate: Always
In this case, the Validate property is very important: choosing "Always" would make "Describe reason" completely bounded to the checkbox, i.e., the user cannot type in this text field unless the checkbox is ticked. But if Validate = "Only when <field> changes", the text field can be entered even if the checkbox is not ticked. |
Message to user: If "Other reason" was chosen, please describe the reason
Be aware that the Is empty function will validate the field in consideration not only on the form or import where it is included, but also outside of these two; for instance, based on the rule above, a form where the "Describe reason" text field is not displayed and the "Other reason" checkbox is just ticked, will still show a warning message and the Save action will not be possible, until "Describe reason" is entered (even from another entry). |
A different example is that if the user chooses the item "Ready to invoice" in the drop-down "Status" then the Note field "Description of the order" is expected to have information. In this case, the note field may be entered even other status.
Valid when: if dropdown item in Status in language of en = Ready to invoice then not Description of the order is empty else Description of the order
Validate: Only when Status changes
Other examples
For File fields: File1 matches .+\.jpg
(the file uploaded must have the JPG extension) or File1 = Report2017.xlsx
(the file uploaded must be named exactly that way with that extension)
For Drop-down fields: dropdown item in Drop-down1 in language of en = dropdown item in Drop-down2 in language of en (the items in two drop-downs must match, and note that "dropdown item in" comes from selecting "itemname" in Funtions) or dropdown item in Drop-down1 in language of en = Cancelled Values are case-sensitive, i.e., typing "cancelled", in lowercase, would not match. Also, if the value of the drop-down is a number, you must use the function string since the list items are strings.