> For the complete documentation index, see [llms.txt](https://docs.work-relay.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.work-relay.com/forms/form-components/components-validation-rules.md).

# Components validation rules

{% hint style="info" %}
One can create validation rule for one of the following field types (both object and virtual fields):

* String
* DateTime
* Rich Text
* Date
* Time
* Textarea
* Number
  {% endhint %}

## Adding validation rule

Choose field to create validation rule (1). Click "Add New" button (2) to open "Validation Rule" popup.

![](/files/092ae03b09711395cb7c11b61045a0baab37661f)

## Validation rule configuration

### Text field

![](/files/fac03552a848109b019d7dee7225493bb28aa258)

Set custom "Error Message" (3) that will be displayed under the field if validation fails.

Configure "Regular expression" (4) to validate field input (optional).

Set "Minimum Length" (5) for the field input (optional).

Set "Maximum Length" (6) for the field input (optional)

Click "Add" button (7) to configure conditions (using standard condition builder) for validation rule to be executed (optional).

{% hint style="warning" %}
Regular Expression, Min Length and Max Length are optional fields, but at least one of those three should be filled in.

Validation rules will not run on empty text fields. A value must be entered to execute the validation.
{% endhint %}

#### Example

Validation rule for text field will show "Invalid value in Sic Desc!" error message if field value contains "BB" substring. It will run only for inputs starting with "TEST" substring.

![](/files/0a3976ce6be3bd186fb29b5a8e5d78057ce424f7)

### Date field

Set custom "Error Message" (8) that will be displayed under the field if validation fails.

Set start value "Minimum" (9) of the allowed date range (optional).

Set end value "Maximum" (10) of the allowed date range (optional).

Click "Add" button (11) to configure "Excluded values" from the allowed date range (optional).

{% hint style="info" %}
If Minimum and Maximum values are not provided all dates are allowed to be entered except Excluded date(s).
{% endhint %}

Click "Add" (12) button to configure conditions (using standard condition builder) for validation rule to be executed (optional).

![](/files/e8dad453abc7893101b3469e75c1166cb765ad62)

You can choose "Excluded Values" type (13) to match your needs:

![](/files/72fcc7d556b0d48395a2bf3e1639e4a23a63141e)

#### Example

Validation rule for date field will show "Invalid date entered!" error message if:

* User entered the date not within specified date range OR
* Entered date value is within the range, but weekday is Wednesday.

![](/files/6b4ec1c4e07f8e2b2b620e9640125c05c57d7591)

### DateTime field

Set custom "Error Message" (14) that will be displayed under the field if validation fails.

Set start value "Minimum" (15) of the allowed date range (optional).

Set end value "Maximum" (16) of the allowed date range (optional).

Click "Add" button (17) to configure "Excluded values" from the allowed date range (optional).

{% hint style="info" %}
If Minimum and Maximum values are not provided all dates are allowed to be entered except Excluded date(s).
{% endhint %}

Configure conditions (18) using standard condition builder for validation rule to be executed (optional).

![](/files/a7a35af84e8cff29dcfbe415b1969b9c5475a6da)

#### Example

Validation rule for DateTime field will show "Please enter correct date!" error message if:

* User entered the date which is earlier than March 1, 2020 11 AM OR
* Entered date value is within May, 2020.

![](/files/409bd95b3bb0078a00b5a436e21e635b4bf311bc)

### Time field

Set custom "Error message" (19) that will be displayed under the field if validation fails.

Set start value "Minimum" (20) of the allowed time range (optional).

Set end value "Maximum" (21) of the allowed time range (optional).

Click "Add" button (22) to configure "Excluded values" from the allowed time range (optional).

{% hint style="info" %}
If Minimum and Maximum values are not provided all time values are allowed to be entered except Excluded values(s).
{% endhint %}

Configure conditions (23) using standard condition builder for validation rule to be executed (optional).

![](/files/9aa139539fc060a36c6c4ab1a1587c8389f3d992)

#### Example

Validation rule for time field will show custom error message if user entered time value within "Excluded Values" time range.

![](/files/292d869f116742acb66b756e4bd60ab7adcc103f)

### Number field

Set custom "Error message" (24) that will be displayed under the field if validation fails.

Set "Minimum" (25) allowed number (optional).

Set "Maximum" (26) allowed number (optional).

Click "Add" button (27) to configure "Excluded values" from the allowed time range (optional).

{% hint style="info" %}
If Minimum and Maximum values are not provided all numbers are allowed to be entered except Excluded values(s).
{% endhint %}

Configure conditions (28) using standard condition builder for validation rule to be executed (optional).

![](/files/ce197a231b5abba4944f79fbb352f90100f28ca7)

#### Example

Validation rule for number field will throw custom error message if:

* user entered one of the static type "Excluded values" (5 or 10 or 15) OR
* user entered number between 100 and 150 OR
* user entered negative value.

![](/files/ffa2799dfcd721a0769be8b952d26f7fa013893a)

### List component

Add a list to the form (29).

Check "Show checkboxes" option (30).

Click "Add New" button (31) under "Validation Rules" section.

![](/files/707462fa4f729485dee633b56fd32bfe711364f7)

{% hint style="info" %}
Validation rules are available only for lists with checked "Show Checkboxes" option.
{% endhint %}

Set custom "Error message" (32) that will be displayed under the field if validation fails.

Set minimum allowed number of checked rows (33) (optional).

Set maximum allowed number of checked rows (34) (optional).

Click "Add" button (35) to configure "Excluded values" from the allowed range (optional).

{% hint style="info" %}
If user checks one of the excluded records rule will show error.
{% endhint %}

Click "Add" button (36) to configure conditions (using standard condition builder) for validation rule to be executed (optional).

![](/files/717b4219b475d797acf6c8ca1af95d1232534e72)

#### Example

Validation rule will work when "Active" field = "Yes" (Condition matched) and will throw error if:

* User checked less than 3 list entries OR
* User checked more than 100 list entries OR
* User checked at least one entry with ID from the excluded values.

![](/files/540baee251bff2921d8956a4072289e59e730db4)
