Documentation

Data Enum

Enumerated data that holds only one of a predefined set of values

2 min read

A Data Enum is a data type that can hold only one of a predefined set of values. For example, a to-do's priority must be one of low, medium, or high, and an order status can only be one of fixed values like pending, paid, or shipped.

Restricting the range of values prevents invalid values from being entered and also makes choosing a value more convenient.

Creating an Enum

In the Data Scheme sidebar, you can create an Enum alongside a regular Schema. An Enum consists of the following.

  • name — e.g. Priority
  • baseType — the base type of the values. string or integer
  • list of values — the allowed values. e.g. low, medium, high

Using an Enum in a field

Choose enum as a Schema field's type and assign the Enum you created. That field can then hold only the values defined in the Enum.

When editing the data value, a Picker appears instead of free input, so you can only choose from the defined values. When serialized to JSON, the value is stored as a string or a number depending on the baseType.

When you import OpenAPI/Swagger or a JSON Schema, the enumerations defined in the spec are automatically created as Data Enums. Identical sets of values are consolidated into one with no duplicates.