Validation rules

The API builder empowers you to apply various validation rules tailored to different field types. Validation rules encompass the procedures for verifying that data inputted into a database adheres to predefined regulations, norms, and limitations. Within the API builder and depending on the field type, you can implement the following types of validation:


Min-max character validation

Min-max character validation ensures that the length of a text string falls within a specified range of characters.

  • Min char length (min)

    The "min" part of min-max character validation specifies the minimum number of characters that a text string must contain to be considered valid. If the entered text has fewer characters than the specified minimum, the validation will fail, and an error message is displayed to the user. ➑️ Example: A password must have a minimum of 8 characters.

  • Max char length (max)

    The "max" part of min-max character validation sets the maximum allowed number of characters for a text string. If the entered text exceeds this maximum limit, the validation will fail, and an error message is shown to the user. ➑️ Example: A username cannot exceed 20 characters in length.


Max decimal places

Max decimal places validation ensures that a number doesn't exceed the specified number of decimal places.

➑️ Example: A price field must have max 2 decimal places in most countries.


Regex

Regex validation allows to validate a string or number against a regular expression formula.

Examples of valid regular expressions are: [a-zA-Z]+ and ^\d{3}$.

It uses the Python module re to test value against regular expressions, with the Unicode flag enabled. To quickly test a regular expression on your environment, you can use the following Python code:

result = re.fullmatch(your_regex, your_value, flags=re.UNICODE)
return result is not None

Unique

Unique validation specifies that the field accepts only non-repeating values.

Please note that this validation rule is not retroactive and only applies to new entries.


Min-max list items validation

Min-max list items validation ensures that the number of items (rows) in a list falls within a specified range.


Maximum file size

Max file size validation ensures that the size of a file (e.g. image, video, document) being uploaded or processed does not exceed a maximum size in megabytes (MB).


Accepted extensions

Accepted extensions validation ensures that files being uploaded or processed have file extensions that match a predefined list of accepted file types. This type of validation is used to restrict the types of files that can be uploaded or processed.


Whitelist validation

"Whitelist validation” works by defining a specific list or set of valid inputs, and any data that does not match these predefined values is considered invalid and rejected. For example, when a web form collects country names, a whitelist of valid country names is created. When a user submits their country, the input is compared to the whitelist. If it matches one of the allowed country names, it is considered valid. Otherwise, it's rejected as invalid input.


Required field

Required fields are essential to ensure that vital information is provided and that important fields are not left empty during data entry or form submission. This validation is crucial for preserving data integrity and accuracy. Depending on the type of field being validated, three different types of required field validation may be available:

  • Always An "always required field" describes a field for which it is mandatory to contain data or be filled out by the user before they can proceed with a form submission or data entry.

  • Never A "never required field" describes a field which does not need to contain data or be filled out by the user before they can proceed with a form submission or data entry.

  • Only if another top field is present An "only if another top field is present" describes a specific type of data validation that imposes a condition on whether a field is required or not based on the presence or content of another related field. ➑️ Example: In an RSVP form for a wedding reception, there are two fields: "Number of Guests" (a numeric input) and "Guest Names" (a text input). If the user enters a number greater than 1 in the "Number of Guests" field, the "Guest Names" field becomes required, and they must provide the names of their guests attending the event. This conditional requirement ensures that guest names are collected only when multiple guests attend.


CMS preview toggle

The API builder provides the capability to manage the inclusion of fields on the CMS preview page associated with specific database or screen APIs. By activating the CMS preview toggle, you can selectively showcase a particular field on the CMS preview page related to a database or static screen. For instance, when the toggle is turned on, an image field within a blog entry will automatically appear as a thumbnail on the blog entries list page.

Last updated