II. Validation
Most types of properties require some form rendering on the interface. Images, videos or input fields are all examples
of properties that require some form of specific display that is not just a simple text field. To make sure such
properties are properly displayed we are using the files from validation
directory.
Supported validations
Name | Description |
---|---|
required | Enforce a field as obligatory; otherwise, display an error message. |
minLength | Enforce a minimum character length constraint on a field; otherwise, display an error message. |
maxLength | Enforce a maximum character length constraint on a field; otherwise, display an error message. |
min | Enforce a minimum value constraint on a field; otherwise, display an error message. |
max | Enforce a maximum value constraint on a field; otherwise, display an error message. |
Validate the field to ensure it contains a properly formatted email address; otherwise, display an error message. | |
regex | Apply a regular expression pattern to the field for validation; otherwise, display an error message. |
date | Validate the field for proper date formatting; otherwise, display an error message. |
range | Ensure the field value falls within a specified range; otherwise, display an error message. |
content-type | Validating files based on their mime type. |
Example
Except for rendering, validations play an important role in making sure the input is correct. For example, if you want to make sure the user enters a number or the property is required, you can set up a validation that checks if this conditions were met.
{
"$type": "validation",
"$author": "Andrei",
"validations": {
"name": {
"required": true
},
"x": {
"required": true,
"regex": "[a-zA-Z0-9]"
},
"y": {
"required": true,
"regex": "[a-zA-Z0-9]"
},
....
}
}