Skip to main content

Custom Data Types

Every attribute in a resource has a data type. Most of the time that's one of the built-in types — String, Int, Timestamp, Image, and so on. When the built-in types aren't enough, you define a custom data type and reuse it across resources.

Custom data types are managed from the Data Types tab of the Data page.

The three kinds

Enum

A set of named values. Use an enum when a field should only ever hold one of a fixed list of options — a status, a tier, a category.

Defining the allowed values in the type rather than validating them per field means every resource that uses the enum stays consistent, and the dashboard can render the field as a proper picker.

Object

A collection of named fields, each yielding a value of a specific type. Use an object when several values always travel together — a postal address, a set of dimensions, a price with its currency.

An object's fields are ordered, and you can rearrange them by dragging. The order is what the dashboard uses when it renders the type.

An object can also nominate a title field, which is the field DashX displays when it needs to show one of these values as a single line of text.

Union

Allows a value to be one of several specified types. Use a union when a field is genuinely polymorphic — a notification payload that differs by channel, or a content block that could be text, an image, or a video.

A union is defined by choosing its member types. You can pick types that already exist, or author a new member type inline without leaving the form.

Creating a custom data type

  1. Open DataData Types and create a new data type.
  2. Enter a Name; the Identifier is derived from it automatically.
  3. Choose the kind — Enum, Object, or Union.
  4. Fill in the kind-specific part: the allowed values for an enum, the fields for an object, or the member types for a union.
  5. Save.

For an object, each field is added through its own editor, where you set the field's name, its type, and any validations that should apply to it. Fields can be reordered by dragging, and nested objects can be authored inline.

Once saved, the custom type is available anywhere you pick a data type — including as the type of a field inside another custom data type.

See also

  • Data Types — reference for the built-in types.
  • Resources — where data types get used, as resource attributes.