Skip to main content

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

NameDescription
requiredEnforce a field as obligatory; otherwise, display an error message.
minLengthEnforce a minimum character length constraint on a field; otherwise, display an error message.
maxLengthEnforce a maximum character length constraint on a field; otherwise, display an error message.
minEnforce a minimum value constraint on a field; otherwise, display an error message.
maxEnforce a maximum value constraint on a field; otherwise, display an error message.
emailValidate the field to ensure it contains a properly formatted email address; otherwise, display an error message.
regexApply a regular expression pattern to the field for validation; otherwise, display an error message.
dateValidate the field for proper date formatting; otherwise, display an error message.
rangeEnsure the field value falls within a specified range; otherwise, display an error message.
content-typeValidating 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]"
},
....
}
}
OpenfabricAI Footer