Validation Rules

Validation rules allow you to check record values prior to submission to a database. If values match condition criteria, a message will be displayed to a user – either near a specified column, or on top of the form. Creating validation rules you can implement a range of restrictions varying from simple sanity checks such as one depicted below to complex conditions. For instance, there is Finding Duplicate Entries template, where the validation rule is created in the Companies table to prevent creation of duplicates (companies with the same names).

Here is another validation rule example that controls End Date and Start Date accuracy. Let’s assume that in your business process an End Date value should be greater than a Start Date value. So you need to exclude incorrect cases when [End Date]<=[Start Date] . As a result, you can create the validation rule preventing inaccurate data entries.


To add a new Validation Rule:

Click the Setup link in the top right corner of the window.

Choose a necessary table and click a corresponding tab at the top of the window.

From the menu in the main frame select Rules > Validation Rules.

Click New at the top of the actions list. The system will open the following form:

Condition

In the Condition field specify a condition that will trigger a certain action if it is met.

Message

Enter a message that should be shown, if values mismatch the condition criteria.

Location

Select a record field where the message will be shown.

Enabled

Leave this checkbox ticked, if you want to enable the created validation rule, or uncheck it if you don’t want to activate it.

Please note that Validation Rules are low-level constraints and are applied not only to editing operations but also to imports and operations via API.


Validating user input against character pattern

TeamDesk supports validation rules to check if a user input is correct. Validation rules allow you to check whether the values entered are in a certain range or correlate to each other. However, checking a text against a pattern, such as SSN number is a non-trivial task.

To help dealing with patters we are introducing Match(text, pattern) function. The first argument can be any type of text expression. The second argument is a text literal specifying the regular expression to check.

The regular expression language is very powerful and capable to handle a variety of scenarios ranging from simple to quite complex. Many of samples for everyday use can be found in the Internet. Here are just two examples:

"^[0-9]{3}[ -]?[0-9]{2}[ -]?[0-9]{4}$"

checks if the text looks like SSN number – has the group of three digits followed by the group of two then by group of four digits. Yet, this expression passes invalid SSN 000-00-0000. Below is more complicated example that rejects SSN containing all-zero groups and not-yet-allocated numbers (those that starts with 7-9)

"^(?!000)([0-6][0-9]{2}|7([0-6][0-9]|7[012]))[ -]?(?!00)[0-9]{2}[ -]?(?!0000)[0-9]{4}$"

Please note that Match() is a relatively time-consuming function and currently its usage is limited to validation rules only.

Next: Workflow Triggers