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. You can configure validators for each of the attribute fields. 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 this field must be filled out. It does not require any additional settings.
Trimming Whitespace Around Input Data
This rule indicates that whitespace at the beginning and end of the string will be removed. It does not require any additional settings.
String Validation
This rule allows you to configure parameters for text types. In the additional settings, you can specify a fixed string length or set a range using minimum and maximum values.
URL Validation
This rule allows you to set a string value only if it is a link. It does not require any additional settings.
Number Validation
This rule checks whether the value is a number. In the additional settings, you can specify whether the number is an integer, as well as set minimum and maximum values for the number.
Number Rounding
This rule does not check the value for numeric type. Instead, it performs rounding of the number according to the rules specified in the additional settings. In the additional settings, you can specify the order and rule for rounding the number.
Email Validation
This rule checks whether the value is a string. It does not require any additional settings.
Default Value
This rule will set a default value for the attribute if no value has been entered. In the additional settings, you can specify the value that will be set as default.
List Validation
This rule checks whether the input value in the attribute matches one of the values specified in the validator's list. In the additional settings, you can specify values separated by commas, as well as set logical negation.
Field Mask
This rule checks whether the input data matches the mask. In the additional settings, you can specify the mask using special characters.
Regular Expression Validation
This rule checks whether the input data matches a regular expression. In the additional settings, you can specify the 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 the 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 the additional settings, you can configure the interpretation of non-boolean values.
Size
This rule checks the size of the image. In the additional settings, you can configure the height and width of the image in pixels.
File Validation
This rule checks the uploaded file against the parameters. In the additional settings, you can configure the minimum and maximum values for file weight units, as well as the type of measurement units.
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.
Examples
Example of Email Field Validation.
In this example, the string value will be added:
- Removal of possible whitespace at the beginning and end of the string
- Check that the string is an email
Example of Password Field Validation.
In this example, the string value will be added:
- Length and composition check of the string using a regular expression
Example of Image Field Validation.
In this example, the string value will be added:
- Check the dimensions of the image
- Check the weight of the image
- Custom error