Validators
Validators are a set of rules that will check the content of an attribute when entered into the system and reject the addition of data if it does not meet these rules. For each attribute field, you can configure validators. This can be done by going to the attribute field settings and scrolling down to the "Validation Rules" section.
The set of validators may vary depending on the data type.
Types of Validators
Each data type has its own set of available validators. Below are all possible validators for all data types you may encounter.
Required Field
This rule indicates that the field must be filled out. It does not require additional settings.
Trimming Spaces Around Incoming Data
This rule indicates that spaces at the beginning and end of the string will be removed. It does not require additional settings.
Checking the String
This rule allows you to configure parameters for text type. In additional settings, you can specify a fixed string length or set a range using minimum and maximum values.
URL Verification
This rule allows you to set a string value only if it is a link. It does not require additional settings.
Checking for a Number
This rule checks whether the value is a number. In additional settings, you can specify whether the number is an integer, as well as set minimum and maximum values for the number.
Rounding a Number
This rule does not check the value for a numeric type. Instead, it performs rounding of the number according to the rules specified in the additional settings. In additional settings, you can specify the order and rule for rounding the number.
Email Verification
This rule checks whether the value is a string. It does not require additional settings.
Default Value
This rule will set a default value for the attribute if no value has been entered. In additional settings, you can specify the value that will be set by default.
Given List Screening
This rule checks whether the entered value in the attribute matches one of the values specified in the validator's list. In additional settings, you can specify values separated by commas, as well as set logical negation.
Field Mask
This rule checks whether the entered data matches the value of the mask. In additional settings, you can specify the mask using special characters.
Regular Expression Validation
This rule checks whether the entered data matches a regular expression. In additional settings, you can specify a regular expression. You can learn more about regular expressions "here".
Although you can add multiple validators to a single attribute field, validation using regular expressions is not compatible with some other types of validation.
Comparison
This rule compares the value of the specified attribute with another to ensure that their relationship matches the comparison described in the property. In additional settings, you can specify the type and value of the comparison, as well as the comparison operator.
Logical
This rule checks whether the attribute value is logical. In additional settings, you can configure the interpretation of non-boolean values.
Size
This rule checks the size of the image. In additional settings, you can configure the height and width of the image in pixels.
Checking Files
This rule checks the uploaded file for compliance with the parameters. In additional settings, you can configure minimum and maximum values for file weight units, as well as the type of measurement units.
Date and Time Range for Restriction
This rule restricts the values that can be selected in the attribute. Available for "Date and Time", "Date", and "Time" types. In additional settings, specify the lower and upper limits in the Minimum date and time value and Maximum date and time value fields — the format of the fields corresponds to the attribute type (date, time, or date with time). If the selected value is out of bounds, the user will see an error message.
Custom Errors
You can add error text to each validator. This text will be visible to the user if the validator does not allow the data. This can be done through the validator settings, in the Custom error field: the specified text replaces the standard validation error message.
Examples
Example of Email Field Validation
In this example, the string value will be added:
- Removal of possible spaces at the beginning and end of the string
- Checking that the string is an email
Example of Password Field Validation
In this example, the string value will be added:
- Checking the length and composition of the string using a regular expression
Example of Image Field Validation
In this example, the string value will be added:
- Checking the dimensions of the image
- Checking the weight of the image
- Custom error