Skip to content

Latest commit

 

History

History
1158 lines (912 loc) · 57.6 KB

field-types.mdx

File metadata and controls

1158 lines (912 loc) · 57.6 KB
title Field types — the complete visual gallery
navTitle Field Type Gallery
description Complete reference for every ObjectStack field type with per-type configuration properties

ObjectStack provides a comprehensive set of field types covering every data modeling need — from basic text and numbers to AI vectors and rich media. This guide organizes them by category with per-type configuration details.

**Source:** `packages/spec/src/data/field.zod.ts` **Import:** `import { FieldType, FieldSchema } from '@objectstack/spec/data'`

Each type below also says what the Console does with it: the form widget, the read-only display and the grid cell. Behaviour shared by many types, such as the empty-value affordance and the keys a widget receives at runtime, is described once under How the Console renders a field.


Text Types

text

Single-line plain text input.

Property Type Default Description
maxLength number — Maximum character length
minLength number — Minimum character length
format string — Display hint, not validation — the server runs no check from it. The UI's cell-renderer resolver reads a small set of words and renders the cell as the richer type: phone / tel / telephone (a tel: link), email (a mailto: link), url / uri / link (a clickable link), currency / money, percent / percentage; any other word renders as plain text. To reject a malformed email, URL or phone number, use that field type instead, or a format validation rule
valueDomain 'iana_time_zone' | 'iso_4217_currency' | 'iso_3166_alpha2' — Standard the written value must be a member of (IANA time zone, ISO 4217 currency code, ISO 3166-1 alpha-2 country code); text only
{ name: 'first_name', label: 'First Name', type: 'text', maxLength: 100 }

In the Console: a single-line input. placeholder is shown inside the empty input and inlineHelpText beside it. A regex check is not a field key (FieldSchema is strict and refuses pattern); declare a format validation rule on the object instead. The form does not pre-check that rule in the browser: a value that breaks it is refused when the record is saved, with the rule's message as the reason. In a grid the value is truncated to the column width.

textarea

Multi-line text input for longer content.

Property Type Default Description
maxLength number — Maximum character length
minLength number — Minimum character length
{ name: 'description', label: 'Description', type: 'textarea', maxLength: 5000 }

In the Console: a multi-line editor. rows sets the inline editor's height in text rows (fullscreen and dialog editors size themselves). maxLength is also the editor's native stop and drives a {n}/{max} character counter. In a grid long text is truncated.

email

Email address with built-in format validation.

Property Type Default Description
maxLength number — Maximum character length
{ name: 'email', label: 'Email', type: 'email', required: true, unique: 'organization' }

In the Console: an email input. Read-only, and in a grid, the value is a mailto: link. The address shape is checked on the server's write path, so a malformed address is refused on save whatever the client sent.

url

URL with format validation.

Property Type Default Description
maxLength number — Maximum character length
{ name: 'website', label: 'Website', type: 'url' }

In the Console: a URL input. Read-only, and in a grid, an http:// or https:// value is a link that opens in a new tab with rel="noopener noreferrer". Any other scheme (javascript:, data:) is shown as plain text, never as a link.

phone

Phone number field.

Property Type Default Description
maxLength number — Maximum character length
{ name: 'phone', label: 'Phone', type: 'phone' }

In the Console: a tel input, which opens the dial pad on a phone. Read-only, and in a grid, the value is a tel: link. The widget applies no input mask: the value is stored as typed.

password

Masked password input. On a generic object the value is plaintext at rest but masked to •••••••• on read (ADR-0100) — it is not one-way hashed. One-way hashing is owned by the auth subsystem and applies only to its identity tables, never to an authored password field. For reversible encrypted-at-rest secrets (API keys, tokens, DB passwords), use the secret type instead; for login credentials, model them on the auth user object.

{ name: 'password', label: 'Password', type: 'password', required: true }

In the Console: a masked input with a show/hide toggle. Read-only, and in a grid, a stored password or secret value is drawn as a fixed mask (••••••), never as the value. An empty value draws the shared "No value" affordance instead, so a credential that was never set is distinguishable from one that is.

secret

Reversible, encrypted-at-rest value (DB password, API key, token). Unlike password (masked on read but plaintext at rest, or one-way hashed inside the auth subsystem), a secret is encrypted on write via the registered crypto provider, stored as an opaque ref on the row, and masked on read. Fail-closed: with no provider configured, writes throw rather than persist cleartext.

{ name: 'api_key', label: 'API Key', type: 'secret' }

Querying a password or secret field. Neither type is a filter, sort or aggregation key. Only a has-a-value check is accepted on one: { "$null": true | false }, { "$exists": … }, { "$empty": … }, or equality with null. Any other operator in where or filter (equality with a value, a range, $startsWith / $contains, $in, a { "$field": … } comparand), an orderBy entry, a group-by or a min / max over one is refused with 400 INVALID_FIELD before the query runs. That holds for every caller, administrators included. A search also never scans such a column, even one listed in searchableFields. Only server-side code running as the system context may match on the stored value (ADR-0100).


Rich Content Types

markdown

Markdown-formatted text with preview support.

Property Type Default Description
maxLength number — Maximum character length
{ name: 'readme', label: 'README', type: 'markdown' }

html

Rich HTML content.

Property Type Default Description
maxLength number — Maximum character length
{ name: 'body', label: 'Body', type: 'html' }

richtext

WYSIWYG rich text editor content.

Property Type Default Description
maxLength number — Maximum character length
{ name: 'content', label: 'Content', type: 'richtext' }

In the Console: markdown, html and richtext share one editor, and type changes only how the stored text is displayed. richtext stores HTML and is displayed through the same pipeline as html. The editor is a plain textarea today: there is no formatting toolbar, preview pane or WYSIWYG mode, so toolbar, preview, minHeight and maxHeight are not field keys. rows sets the inline editor's height, and maxLength adds a native stop and a character counter, inline and in the fullscreen editor a form opens when it sets mobile.fullscreenLongText.

Grids, record pages and read-only forms render the stored markup formatted. HTML is sanitized against a GitHub-style allow-list: links keep http, https, mailto and relative URLs, images keep http, https and relative URLs, and inline style, event-handler attributes, frames, objects and SVG or MathML content are not rendered. An element outside the allow-list shows its text without its tag. The markdown pipeline uses the same allow-list.


Number Types

number

Numeric value with optional precision.

Property Type Default Description
precision number — Total digits
scale number — Decimal places
min number — Minimum value
max number — Maximum value
{ name: 'quantity', label: 'Quantity', type: 'number', min: 0, max: 99999 }

In the Console: a numeric input with a stepper (step sets the increment). The read-only display and the grid cell use tabular figures and show the value to the field's scale: a stored 1234.5 reads 1,234.50 at scale: 2 and 1,234.5 with no scale. Thousands separators follow useGrouping:

useGrouping scale Separators
false any none: 12345.5
true any always, even where the locale leaves four-digit numbers alone: 2,026
not set 0 none, since the value reads as a year or another ordinal: 2026
not set anything else, or not set the locale's own convention: 12,345.5

The input is a native number box, so the browser filters what is typed. See What a number input silently rewrites.

currency

Monetary value. The stored value is a bare number in every mode; the currency code lives in currencyConfig, or under record in a sibling code field, never in the value. See Currency fields for the three modes and what a record-currency amount refuses.

Property Type Default Description
precision number — Total digits
min number — Minimum value
max number — Maximum value
currencyConfig.currencyMode 'dynamic' | 'fixed' | 'record' 'dynamic' Whether the column is pinned to defaultCurrency (fixed), displays in the tenant default currency, the localization.currency setting (dynamic), or takes each record's own code from the field currencyField names (record); the value is a bare number in every mode
currencyConfig.defaultCurrency string — The column's currency code under fixed, where it is required; not the displayed currency under dynamic; refused under record
currencyConfig.currencyField string — record only, and required there: the field on the same object holding each record's ISO 4217 code, a text field with valueDomain: 'iso_4217_currency' (conventionally currency_code); refused under dynamic and fixed
currencyConfig.homeAmount object — record only, and optional there: where the engine stores the amount converted into the home currency (the localization.currency setting) and the rate it used. Three required pointers into the same object: field, a dynamic-mode currency field declaring readonly: true; rateDate, a date or datetime field holding the document date that picks the rate; rateField, a number field declaring readonly: true. Refused under dynamic and fixed. See Declaring the home amount
{ name: 'price', label: 'Price', type: 'currency', currencyConfig: { currencyMode: 'fixed', defaultCurrency: 'USD' } }

A currency amount's decimal places are its currency's ISO 4217 minor unit (2 for USD, 0 for JPY, 3 for KWD), not a field setting, and they are declared nowhere. A currency field takes no scale, and currencyConfig has no decimal-places key: publish-time validation refuses scale on the field and currencyConfig.precision (removed in @objectstack/spec 17.5.0 — no renderer or runtime ever read it), each with a prescription to delete the key. The field-level precision is the amount's total digit count — a DECIMAL(18,2) amount declares precision: 18 — and is never compared with the currency.

In the Console: a numeric input with the currency's symbol. The read-only display, the grid cell, the input's step and the rounding applied when the input loses focus all use the currency's minor unit, so a JPY amount shows no decimals and a KWD amount shows three. With no currency resolved at all, an amount shows two decimals. A record-mode amount resolves only its own record's code, never the tenant default. A field-level currency key is refused: the currency is currencyConfig. The input is a native number box; see What a number input silently rewrites.

percent

Percentage value (0–100 or decimal).

Property Type Default Description
precision number — Total digits
scale number — Decimal places
min number — Minimum value
max number — Maximum value
{ name: 'discount', label: 'Discount', type: 'percent', min: 0, max: 100 }

How a percent is stored. A percent field stores a fraction unless it declares a max above 1, in which case it stores whole percentage points (percentScaleOf in @objectstack/spec/data). With no max, or max: 1, a stored 0.75 is displayed as 75% and a typed 90 is stored as 0.9. With max: 100 (any max above 1), a stored 75 is 75% and a stored 1 is 1%. Every surface reads the same declaration (the input, the read-only text, the grid cell and footer, the record header, gantt tooltips, gallery cards and dashboard tiles), so one stored value shows one percentage everywhere; none of them guesses the storage from the value's size.

In the Console: scale is the number of decimals the percent shows, in the input's step, the read-only display and the grid cell: a stored 0.855 shows 85.50% at scale: 2 and 86% with no scale. precision is the stored total digit count and never sets the displayed decimals. The input is a native number box; see What a number input silently rewrites.


Date & Time Types

date

Date value (no time component).

{ name: 'birth_date', label: 'Birth Date', type: 'date' }

In the Console: a date picker. A date is a calendar day and shows the same day in every time zone. The grid cell shows a relative face ("3 days ago") for recent dates and an absolute date otherwise. There is no date-range key: a field's min / max are numbers, so bound a date with a validation rule. A date can be declared a deadline; see Deadlines: dueLike and settledWhen.

datetime

Date and time value with timezone support.

{ name: 'created_at', label: 'Created At', type: 'datetime', readonly: true }

In the Console: a combined date and time picker. A datetime is an instant and renders in the workspace's time zone, the timezone that GET /api/v1/auth/me/localization answers; without one it renders in the viewer's own zone. A datetime can be declared a deadline; see Deadlines: dueLike and settledWhen.

time

Time-only value (no date component).

{ name: 'start_time', label: 'Start Time', type: 'time' }

In the Console: a 24-hour HH:mm time input (14:30 is 2:30 PM).

Deadlines: dueLike and settledWhen

dueLike: true declares a date or datetime field a deadline. Once it has passed, the Console shows relative overdue wording ("Overdue 3d") instead of the neutral "3 days ago", and colours the value red. Without the key nothing is inferred from the field's name: a past due_date reads like any past date. Both keys are refused on any other type, and both are display only: nothing on the write path reads them.

settledWhen says when the deadline is settled for one record: a CEL predicate over the record's own columns, read as record, written as a string or as the expression envelope. It is accepted only beside dueLike: true. While it holds, no overdue wording or colour applies to that record.

{ name: 'due_date', label: 'Due Date', type: 'date', dueLike: true, settledWhen: "record.status == 'done'" }

Every view that draws the date beside its record (the grid, the record page, related lists, kanban and gallery cards, the compact list and the tree) evaluates settledWhen against that record, so a done task's past due date reads neutral while an open one's reads overdue. A predicate that fails to evaluate leaves the deadline unsettled.

  • The predicate reads the record as the view fetched it. A grid, a list view and a related list add the fields settledWhen reads to their own query, so those fields need not be columns. A field the viewer may not read is never fetched, so for that viewer a deadline whose predicate reads it stays unsettled. An approval's record summary judges the deadline against the snapshot it shows.
  • The affordance is day-granular. It compares calendar days, so a datetime a few hours past its deadline still reads "Today" and is not red. The red starts the day after the deadline; the "Overdue Nd" wording starts a day later (the shortest is "Overdue 2d") and stops once the relative face falls back to an absolute date. The red does not stop with it: a long-overdue deadline reads as a plain past date, in red.

Boolean Types

boolean

Standard true/false field.

{ name: 'is_active', label: 'Active', type: 'boolean', defaultValue: true }

In the Console: a switch in forms. Read-only, a true reads "Yes" and a false reads "No"; in a grid the value is a disabled checkbox named by the field's label. A field named completed, is_completed, done or is_done draws a green "Completed" or an outlined "Not completed" indicator instead; every other name, active and enabled included, draws the checkbox.

Only a real boolean is a value of a boolean field: the wire value of boolean and toggle is a JSON boolean. null, 0, 1, '', 'true' and 'false' all draw the "No value" affordance, because the record holds no boolean there. Repairing SQL 0/1 or the strings 'true' / 'false' is the producer's job (driver read-coercion, CSV import), never the widget's.

toggle

Toggle switch (functionally identical to boolean, different UI).

{ name: 'notifications_enabled', label: 'Notifications', type: 'toggle' }

Selection Types

select

Single-choice dropdown.

Property Type Default Description
options SelectOption[] required (or picklist) List of available options — non-empty. Name a shared list with picklist: 'NAME' instead, never both. With neither, a select (or radio) is refused at parse.

SelectOption properties:

Property Type Required Description
label string ✅ Display label
value string ✅ Machine value (snake_case)
color string — Badge color
default boolean — Pre-selected option
{
  name: 'status', label: 'Status', type: 'select',
  options: [
    { label: 'Open', value: 'open', color: 'blue', default: true },
    { label: 'In Progress', value: 'in_progress', color: 'yellow' },
    { label: 'Done', value: 'done', color: 'green' }
  ]
}

In the Console: a dropdown, drawn in grids as a coloured badge per value. An option authored with an empty or whitespace-only label (the field designer writes one when only the value box is filled) is displayed by its value in every option widget (select, multiselect, radio, checkboxes), editable or read-only. That is a display fallback, not a repair: the stored option keeps its empty label, so give every option a real one.

Cascading and gated options. An option's visibleWhen predicate offers the option only while it is true. It reads the live record and current_user, so one mechanism covers both dependent lists (country → province → city) and options offered only to some users. Declare the controlling fields with dependsOn (an array of field names). While any of them is empty the control is gated with a hint ("Select country first") instead of an unfiltered list; when a controlling value changes, the list is re-evaluated and a selection that is no longer offered is cleared. The clear is saved like any other edit: a single select or radio is written as null, and a multiple select keeps only the values still offered.

{
  name: 'province', label: 'Province', type: 'select', dependsOn: ['country'],
  options: [
    { label: 'Zhejiang', value: 'zj', visibleWhen: "record.country == 'cn'" },
    { label: 'California', value: 'ca', visibleWhen: "record.country == 'us'" },
    { label: 'Public (external)', value: 'public', visibleWhen: "'admin' in current_user.positions" },
  ],
}

Option visibleWhen is the one visibility predicate the server also enforces: a write of a value whose predicate is false, or cannot be evaluated, is refused. A third level (city, dependsOn: ['province']) chains the same way. Option lists suit small, static dictionaries; when the data is large, changes over time or is shared across forms, model each level as a lookup with dependsOn, whose candidate query is filtered on the server and paged.

multiselect

Multi-choice dropdown. Same options property as select.

{
  name: 'tags', label: 'Tags', type: 'multiselect',
  options: [
    { label: 'Bug', value: 'bug' },
    { label: 'Feature', value: 'feature' },
    { label: 'Enhancement', value: 'enhancement' }
  ]
}

radio

Radio button group (single choice). Same options property as select.

{
  name: 'priority', label: 'Priority', type: 'radio',
  options: [
    { label: 'Low', value: 'low' },
    { label: 'Medium', value: 'medium', default: true },
    { label: 'High', value: 'high' }
  ]
}

checkboxes

Checkbox group (multi-choice). Same options property as select.

{
  name: 'features', label: 'Features', type: 'checkboxes',
  options: [
    { label: 'Email', value: 'email' },
    { label: 'SMS', value: 'sms' },
    { label: 'Push', value: 'push' }
  ]
}

Relational Types

lookup

Reference to a record in another object (foreign key).

Property Type Default Description
reference string required Target object name (snake_case). A stored-metadata table (sys_metadata, sys_metadata_history) is refused — see below
referenceFilters string[] — Removed (#2377, ADR-0049) — no longer a recognized field property. FieldSchema is a strict object, so an unknown key is rejected with guidance, not silently stripped (ADR-0078): the error echoes the offending key and prescribes the replacement. Use structured lookupFilters + dependsOn instead; see Relationships
deleteBehavior 'restrict' | 'cascade' | 'set_null' 'set_null' Behavior when referenced record is deleted. On a required lookup set_null is escalated to restrict, since a NOT NULL foreign key cannot be cleared — whether the set_null was defaulted or written out explicitly. On a multiple: true required lookup the escalation is judged per referencing row: only a row the member removal would leave EMPTY is refused. cascade and restrict are the values honored as written. Where set_null does run, a multiple: true lookup loses only the deleted member — the other members are kept, and on an optional field a set emptied that way is stored as null, the same as one never set
{ name: 'company', label: 'Company', type: 'lookup', reference: 'account' }

In the Console: a two-level picker.

  • Typeahead. The trigger opens a popover that fetches candidates from the referenced object, searches as the user types (debounced), and shows "Showing X of Y" when there are more. displayField names each candidate's label (default: the referenced object's name or title field) and descriptionField a secondary line under it.
  • Record Picker. A "Browse all" button beside the trigger, and a "Show all results" link in the popover, open a dialog with a multi-column table, server-side search, column sorting, paging and keyboard navigation (arrow keys, Enter or Space to pick). lookupColumns sets its columns (a field name or { field, label, width }), lookupPageSize its page size (default 10), and lookupFilters restricts the candidates. Without lookupColumns the columns are inferred from the display field.
  • Quick create. allowCreate: true offers "Create new" when nothing matches, creating a record from the typed text. It suits objects whose only required field is the display field.
  • Dependent lookups. dependsOn scopes the candidates by sibling fields: an array of field names, or { field, param } entries when the filter parameter differs from the local field name. While a controlling value is empty the trigger is gated ("Select account first"); once it is set, every candidate query (typeahead, Record Picker and people picker) carries it as a filter no user input can override.
{
  name: 'contact', label: 'Contact', type: 'lookup', reference: 'contact',
  displayField: 'name', descriptionField: 'email',
  lookupColumns: ['name', { field: 'email', label: 'Email', width: '220px' }],
  lookupPageSize: 15,
  dependsOn: [{ field: 'account', param: 'account_id' }],
}

In a grid, a lookup shows the referenced record's label, or one chip per record when multiple is set. Which record field a pick stores (id unless told otherwise) is picker configuration, not a field key: FieldSchema refuses idField, and a form entry, an action parameter or an inline grid column sets it instead.

user

Person picker — a lookup specialized to the built-in sys_user object. Stored identically to lookup (foreign key to sys_user.id; multiple: true stores an array) and resolved through the same $expand machinery. Supports defaultValue: 'current_user' to stamp the acting user's id on insert.

Field.user({ label: 'Assignee' })
Field.user({ label: 'Watchers', multiple: true })
Field.user({ label: 'Owner', defaultValue: 'current_user' })

In the Console: a search-first people picker that delegates to the lookup picker with the reference fixed to sys_user, so it searches users by name and email as you type, and shows each candidate's business unit and email beside the name. Read-only and in grids the value is an avatar (initials when there is no image) with the name, and several users show as overlapping avatars with a count. There is no separate owner type: a record owner is a user field named owner, usually readonly with defaultValue: 'current_user', and type: 'owner' is refused.

master_detail

Parent-child relationship (cascading delete by default).

Property Type Default Description
reference string required Target (master) object name. A stored-metadata table is refused — see below
referenceFilters string[] — Removed (#2377, ADR-0049) — no longer a recognized field property. FieldSchema is a strict object, so an unknown key is rejected with guidance, not silently stripped (ADR-0078): the error echoes the offending key and prescribes the replacement. Use structured lookupFilters + dependsOn instead; see Relationships
deleteBehavior 'restrict' | 'cascade' 'cascade' Behavior when parent is deleted. restrict refuses the parent delete while children exist; cascade (and omitting the key) deletes the children with the parent. An explicit set_null is a parse-time rejection on this type (#9689) — a detail row cannot outlive its master; use a lookup if children must survive the parent
inlineEdit boolean | 'grid' | 'form' — Edit child records inline on the parent create/edit form (true = auto-pick, 'grid', or 'form')
inlineColumns array — Optional explicit inline grid columns
inlineAmountField string — Numeric child field used for the inline running total
{
  name: 'order',
  label: 'Order',
  type: 'master_detail',
  reference: 'order',
  inlineEdit: true,
  inlineAmountField: 'line_total',
}

The inline grid in the Console. With inlineEdit: 'grid' (or true resolving to the grid) the parent's form edits the children as rows of a table:

  • Columns. Without inlineColumns the columns are derived from the child object. An explicit column (InlineGridColumn) names the child field in name and may set label, width (pixels), required and type. A column's type is one of nine cell controls: text, number, currency, date, datetime, time, select, lookup and file. Declaring type opts the column out of derivation, so supply what the control needs (options for a select, reference and displayField for a lookup).
  • File cells. A file column is an upload control in the cell, with removable chips and thumbnails for images; accept and multiple restrict it. Derived columns map file, image and avatar child fields to file cells, an image field accepting image/*. Shown as text, a file cell reads the file's name, or a count when it holds several.
  • Booleans. A derived boolean or toggle child field becomes a select cell storing 'true' / 'false', labelled in the session language.
  • Currency. A currency cell shows the resolved currency's symbol, and decimals of that currency's minor unit; prefix replaces the symbol only.
  • Order. When the columns are derived and the child object has a field named position, sort_order, sequence, line_no, line_number or sort, the grid stamps each row's index into it whenever a row is added, removed, duplicated or dragged, so the order is saved with the rows.
  • Total. inlineAmountField names the numeric child field summed into the footer.

inlineEdit: true picks the form factor itself: a child with a single file, image or avatar field keeps the grid, while a form-only field (textarea, rich text, JSON, location) or several rich fields tips it to a per-row form. An explicit 'grid' or 'form' always wins.

A relationship never targets a stored-metadata table

A lookup or master_detail whose reference is sys_metadata or sys_metadata_history is refused by os validate, os build and the object save door alike. Those rows carry serialized metadata bodies, which are served only through the metadata API (GET /api/v1/meta/:type/:name), where the body is projected; the engine never hydrates a reference into them, so $expand would keep the stored id and never nest the row, and a master-detail child's parent root would stay unbound, refusing every write a parent rule judges. To point a record at a metadata item, store its type and name in text fields and read the item through the metadata API.

tree

Self-referential hierarchy (e.g., categories, org chart).

Property Type Default Description
reference string — Optional. If given, must be this object (self-reference) — any other object is refused at parse
{ name: 'parent_category', label: 'Parent Category', type: 'tree', reference: 'category' }

Media Types

Media fields store a reference to an uploaded file. They take the universal field properties (multiple is honored for file and image). Two more field properties apply to the media family (file, image, avatar, video and audio) and constrain the referenced file: accept, the permitted upload types as MIME types or extensions (e.g. ["image/*", ".pdf"]), offered to the file picker and enforced on write; and maxSize, the maximum permitted file size in bytes, enforced on write against the stored file size, not just checked in the browser. A create or update whose referenced file violates either is refused with 400 ERR_FILE_CONSTRAINT, and the error message names the field and the constraint. Storage itself is configured at the storage-provider layer, not on the field.

In the Console: the stored value is the bare sys_file id the upload minted (an array of ids when multiple is set). The widget uploads through the Console's upload provider, and an upload that comes back with no id is refused with "did not complete", leaving the field unchanged. A pick larger than maxSize is refused before the upload starts. A file the reader may not open (its sys_file row is not readable) arrives as { id, metadataRefused: true } and every file, image and avatar renderer draws a lock labelled "Restricted file" instead of a name or thumbnail; the download link still points at the id, and the download endpoint decides access. Records written before files were stored as references may still hold an inline { name, size, mime_type, url } object, which is still rendered and never written.

image

Image file with optional validation.

{ name: 'photo', label: 'Photo', type: 'image' }

Images show as a thumbnail grid in the form, with remove on hover, and as up to three thumbnails plus a count in a grid cell. accept defaults to image/*.

file

Generic file attachment.

{ name: 'attachment', label: 'Attachment', type: 'file', multiple: true }

Files show as a list with names and sizes in the form, and as the file's name (or a count) in a grid cell.

avatar

Profile image (typically square, small).

{ name: 'avatar', label: 'Avatar', type: 'avatar' }

video

Video file attachment.

{ name: 'demo_video', label: 'Demo Video', type: 'video' }

audio

Audio file attachment.

{ name: 'recording', label: 'Recording', type: 'audio' }

Computed Types

formula

Calculated field using a CEL expression (see Expressions).

Property Type Default Description
expression string | Expression required CEL calculation expression
returnType 'number' | 'text' | 'boolean' | 'date' | 'currency' — Declared value type of the computed result. currency: an amount of money, in the currency the formula's own currencyConfig declares (none: dynamic; over record-mode amounts, record with their currencyField)
{ name: 'total', label: 'Total', type: 'formula', expression: 'record.quantity * record.unit_price', returnType: 'number' }

In the Console: the value is computed on the server and shown read-only; the widget never evaluates the expression. The form and the grid cell draw it by returnType: number is formatted as a number field formats it (to the field's scale), boolean as Yes / No in the UI language (a non-boolean reads empty), date as the date field's absolute face (not the grid's relative one), and text in a monospace font. With no returnType, a number is drawn as a number and anything else as text; nothing is inferred from the expression.

expression on a stored field

expression is not only a formula key. On a field of any other type, the engine computes it from the row each write stores and stores the result in the field's column, so a summary can roll the column up. It is computed on every insert and every update by id (the stored row merged with the patch). On a predicate update it is computed only when the patch moves an input: one value is stored for every matched row, and the update is refused (VALIDATION_FAILED, an invalid_value error on the field) when the rows would compute different values. Update those rows by id instead. A value a client sends for the field never stands: it is overwritten by the computed one. When the value sent differs from the computed one, the write still succeeds and reports the field as dropped, under reason: 'stored_expression' (the data API's droppedFields); sending the computed value, or no value, reports nothing. An in-process caller that passes the engine write option strictReadonlyWrites: true is refused instead, with ERR_READONLY_FIELD_REJECTED, and nothing is written; a request body cannot set that option (see WriteObservabilityOptions). The full contract is the expression row of FieldSchema.

// Stored, so a parent `summary` can sum it. A client-sent amount is overwritten.
Field.currency({ label: 'Amount', expression: 'record.quantity * record.unit_price' })

summary

Roll-up summary from child records.

Property Type Default Description
summaryOperations.object string required Child object to aggregate
summaryOperations.field string required for sum, avg, min, max Child field to aggregate; a count counts the child rows and reads no field, so it may omit it
summaryOperations.function enum required count, sum, avg, min, or max
summaryOperations.relationshipField string auto Child FK back to the parent when it cannot be inferred
summaryOperations.filter FilterCondition — Only child rows matching this where predicate are aggregated

A sum, avg, min or max over a child amount declared currencyMode: 'record' is refused when the object registers (INVALID_METADATA / 422): child rows in different currencies would be added into one number. A count is served (Currency fields).

{
  name: 'task_count',
  label: 'Task Count',
  type: 'summary',
  summaryOperations: {
    object: 'task',
    function: 'count',
    relationshipField: 'project',
  },
}

Add a filter to aggregate only a subset of children — this is how one child object feeds several different totals. The engine ANDs the predicate with the parent-FK match and recomputes on the child's next write, so a row moving in or out of the filter (a status change) keeps the parent current:

// Sum only received receipt lines (3-way match), not every line.
{
  name: 'received_amount',
  type: 'summary',
  summaryOperations: {
    object: 'procurement_receipt',
    field: 'amount',
    function: 'sum',
    filter: { status: 'received' },
  },
}

// One `engagement` child → distinct totals, differentiated only by the filter.
{
  name: 'total_signups',
  type: 'summary',
  summaryOperations: { object: 'engagement', field: 'id', function: 'count', filter: { type: 'signup' } },
}

In the Console: the roll-up is shown read-only, drawn by the same rule in the form and the grid cell: a number is formatted as a number field formats it, keeping its own precision unless the field sets a scale (15750.5 reads 15,750.5; at scale: 2, 15,750.50), and anything else is shown as text.

autonumber

Auto-incrementing number with format template.

Property Type Default Description
autonumberFormat string — Format template (e.g., 'INV-{0000}')
{ name: 'ticket_number', label: 'Ticket #', type: 'autonumber', autonumberFormat: 'TKT-{0000}' }
**An autonumber is unique and monotonic per scope — it is not gapless.** Any write that gets rejected after the number was reserved — a unique violation on another field, a failed validation rule, a `beforeInsert` hook that throws — still consumes that number, and it is never reissued. `TKT-0001` succeeding and `TKT-0002` failing means the next row is `TKT-0003`; `TKT-0002` will not exist.

This is a decided property of the counter, not a bug to work around. If you are building an invoice, contract, or receipt sequence on an autonumber field, design for gaps: an autonumber guarantees a unique, ever-increasing business identifier, but it is not a legally gapless document number. Treat that guarantee as a separate requirement to satisfy explicitly, not something autonumber already gives you.

Format tokens. autonumberFormat is literal text with {...} tokens, read by parseAutonumberFormat (@objectstack/spec/data); the query engine and the SQL drivers share one renderer, so these are the whole grammar:

Token Renders
{0}, {00}, {0000}, … The counter, zero-padded to at least that many digits (one per format)
{YYYY}, {YY}, {MM}, {DD}, {YYYYMMDD} The generation date in the business time zone
{field_name} The value of another field on the same record

Date tokens are exact and case-sensitive, and there is no quarter, week or time token: any other name in braces is a field token, so {Q} reads a field called Q. A referenced field must exist on the object and be set before the record is created. The counter is scoped to whatever renders before it, so 'ORD-{YYYY}-{0000}' restarts each year and 'ORD-{0000}' keeps one count. Omitted, the format is {0000}. The older format key is the same pattern and is still accepted, but autonumberFormat wins when both are set.

In the Console: the number is assigned on insert, so a create form shows the field empty and the value appears once the saved record comes back.


Embedded Structured Types

These types store structured values as JSON on the parent row — no separate table or foreign key.

On an object field, `composite` and `repeater` are **untyped JSON** containers of CMS lineage (similar to a Strapi component, an ACF group or an ACF repeater). A field declares no sub-fields: `fields`, `subFields` and `columns` are refused on the field, so nothing gives the inner keys labels, types, options, required flags or translations, and nothing validates or addresses a single row.

A list that needs typed columns is a child object with a master_detail field pointing back at the parent — the shape Salesforce, Dynamics, ServiceNow and Odoo use for line items. The child's own fields carry the types and validation, inlineEdit: 'grid' edits the rows as an inline grid on the parent's form, and every row is a record a lookup, a roll-up or a flow can reach.

composite

A single embedded JSON object, untyped — no declared sub-fields.

{ name: 'dimensions', label: 'Dimensions', type: 'composite' }

repeater

An array of embedded JSON objects, untyped — no declared sub-fields or columns. For typed rows, use a child object (see above).

{ name: 'import_log', label: 'Import Log', type: 'repeater' }
// A typed list: a child object, edited inline on the parent's form
{
  name: 'invoice_line',
  fields: {
    invoice: { type: 'master_detail', reference: 'invoice', required: true, deleteBehavior: 'cascade', inlineEdit: 'grid' },
    product: { type: 'text', label: 'Product' },
    quantity: { type: 'number', label: 'Quantity' },
  },
}

record

Name-keyed map of embedded sub-objects (Record<string, SubObject>). Insertion order is display order. Used for collections where each item has a stable machine name. See ADR-0007.

{ name: 'settings', label: 'Settings', type: 'record' }

Enhanced Types

location

Geographic coordinates. Stored as { lat, lng, altitude?, accuracy? } (lat −90..90, lng −180..180). No per-type config properties. The key names are lat/lng, not latitude/longitude — see LocationValueSchema in field-value.zod.ts (ADR-0104 D1). The schema is strict (#13802): an undeclared key is refused by name, not silently dropped.

{ name: 'headquarters', label: 'Location', type: 'location' }

In the Console: the user types a latitude-then-longitude pair (37.7749, -122.4194) and the value is displayed the same way; only the stored keys are lat / lng. There is no zoom key on the field. To plot the records of an object on a map, use an object-map view or page node whose map input names the field in locationField (with titleField, zoom and a fallback center used when no record matches).

address

Structured postal address. Stored as { street, city, state, postalCode, country, countryCode, formatted } (all parts optional). No per-type config properties. The schema is strict (#13802): an undeclared key such as postal_code or zipCode is refused with a rename to postalCode, not silently dropped.

{ name: 'billing_address', label: 'Billing Address', type: 'address' }

code

Source code with syntax highlighting.

Property Type Default Description
language string — Programming language for highlighting
{ name: 'snippet', label: 'Code Snippet', type: 'code', language: 'typescript' }

json

Raw JSON data.

{ name: 'metadata', label: 'Metadata', type: 'json' }

In the Console: json, composite and record share a JSON text editor. A json value need not be an object: an array, number, string, boolean or null is shown as its JSON text and parsed back as itself. Text that does not parse is refused: it stays in the box marked "Invalid JSON", the value is not updated, and the form will not submit until it parses. An empty box sets null. The editor checks syntax only; a value's shape is declared with a json_schema validation rule on the object, since the field has no schema key.

In a grid a json value is single-line JSON truncated to the column, with the full text in the tooltip. A composite or record value is one line of labelled sub-values instead (labels are the humanized keys), on the record page as well:

composite  { width: 10, height: 20 }                               →  Width 10 · Height 20
record     { primary: { name: "A", score: 9 }, backup: { … } }      →  Primary (Name A · Score 9) · Backup (…)

color

Color picker. Stores the color value as a string. No per-type config properties.

{ name: 'brand_color', label: 'Brand Color', type: 'color' }

rating

Star rating input.

Property Type Default Description
max number 5 Maximum rating value (set by the Field.rating(max) factory)
{ name: 'satisfaction', label: 'Rating', type: 'rating', max: 5 }
// or with the factory:
// satisfaction: Field.rating(5, { label: 'Rating' })

slider

Range slider input.

Property Type Default Description
min number — Minimum value
max number — Maximum value
step number 1 Step increment
{ name: 'confidence', label: 'Confidence', type: 'slider', min: 0, max: 100, step: 5 }

signature

Digital signature capture.

{ name: 'approval_signature', label: 'Signature', type: 'signature' }

qrcode

QR/barcode value rendered as a scannable code. No per-type config properties.

{ name: 'asset_tag', label: 'Asset Tag', type: 'qrcode' }

progress

Progress bar (0–100).

{ name: 'completion', label: 'Completion', type: 'progress' }

tags

Tag input with autocomplete.

{ name: 'labels', label: 'Labels', type: 'tags' }

AI / ML Types

vector

Vector embeddings for semantic search and similarity.

Property Type Default Description
dimensions number required Vector dimensionality (e.g., 1536 for OpenAI embeddings)

An earlier nested vectorConfig object was removed — the field builder no longer emits it and it is ignored. Set the flat dimensions property instead.

{ name: 'embedding', label: 'Embedding', type: 'vector', dimensions: 1536 }
// or with the factory:
// embedding: Field.vector(1536, { label: 'Embedding' })

In the Console: a vector is read-only. The form shows a preview of its first three values to four decimals plus the dimensionality ([0.1234, -0.5678, 0.9012...] (768D)); a grid cell shows [Vector].


Universal Field Properties

These properties are available on all field types:

Property Type Default Description
name string required Machine name (snake_case)
label string — Human-readable display label
description string — Field description / help text
type FieldType required One of the supported field types
required boolean false Whether the field is required
unique boolean | 'global' | 'organization' false ('organization' on autonumber) Unique constraint and its scope (ADR-0120). 'organization' = one holder per organization; true = that same per-organization scope (positional synonym — prefer the explicit spelling in new code); 'global' = one holder across the whole installation; false = no constraint. Omitted ⇒ false, except on an autonumber field, where omitted ⇒ 'organization' — an auto-number is a business identifier, so the platform makes it unique per organization by default; write unique: false explicitly to opt out. 'tenant'/'org' are rejected — the word is 'organization'. Full rule in the unique doc block in FieldSchema
multiple boolean false Allow array of values (multi-record lookup, multi-select, multi-file). An emptied optional multi-value field is stored as null, the same as one never set ([] and "" written to it store null); a row stored before that rule can still hold [], and is_empty matches both — the multiple doc block in FieldSchema
searchable boolean false Search this field when the object declares no searchableFields — any type but secret / password / vector; a declared searchableFields is the whole set
sortable boolean true Allow sorting by this field
hidden boolean false Hide from default views
readonly boolean false Server contract — non-system writes to this field are stripped on both INSERT and UPDATE (the value falls back to defaultValue), not just hidden in the UI (#2948 / #3043)
externalId boolean false Not read: nothing matches on it. A seed dataset names its match field in its own externalId, an import in its mapping's upsertKey
defaultValue any — Default value for new records
group string — Field grouping / section
inlineHelpText string — Inline help tooltip
trackHistory boolean — Render this field's value changes as entries on the record activity timeline
requiredPermissions string[] — Capabilities required to read/edit this field (masked on read, denied on write)
dependsOn string[] — Fields whose values scope this field's options (lookup candidate query; select/radio option gating)
visibleWhen Expression — Show field only when predicate is true
readonlyWhen Expression — Make field read-only when predicate is true
requiredWhen Expression — Require field when predicate is true

How the Console renders a field

Metadata keys and widget props

The keys on this page are metadata: authored on the object, validated when it is published. A field widget also receives props at runtime, and those are never metadata: the live value and its onChange, the host's className and disabled, a data source for widgets that query records, the values of sibling fields for cascades, and the DOM and ARIA attributes the form control minted. Writing one of those on a field definition publishes a key the strict FieldSchema refuses. A custom widget receives the authored field under one carrier (field) beside the props; its type, FieldWidgetComponentProps in @object-ui/fields, is closed, so a misspelled prop is a compile error. Use toDomProps(props) to pass only what may reach a DOM element, never a bare {...props} spread. A field's widget key names a registered component to render it instead of the type's default.

Empty values

An absent value (null, undefined, '' or []) draws one shared "No value" affordance, an em-dash with that accessible name, in every widget and grid cell. A value the wire contract does not allow for the type, such as 'true' on a boolean, draws the same affordance: the renderer keeps no second reading of off-contract data.

What a number input silently rewrites

number, currency and percent render a native type="number" input, so the browser decides what the box accepts, and only one of the two outcomes is announced:

  • Announced. Text the browser cannot read at all (1e, a lone -, a lone .) stays visible while the input's value is empty. The field is marked aria-invalid and reads "Not saved: the text in this box is not a number."
  • Not announced. Text the browser truncates as it arrives: pasting 1.2.3 stores 1.23, and 0x10 stores 10 (on a fractional percent field, 0.0123 and 0.1). The extra characters never reach the form, so no warning is possible.

"No warning" therefore does not mean "the value is right".

Polymorphic pointer pairs (referenceVia)

A text field that declares referenceVia holds a record id of the object its sibling column names, row by row: sys_approval_request.record_id points at the record object_name names, and sys_activity.source_id at the one source_object names. The record details grid resolves the pair from the row with resolveRecordPointer(field, row) and draws it with the renderer registered under RECORD_POINTER_CARD_TYPE. The fields package's default draws the record id as text; the console registers a record preview card there, so a pointer field on a record page shows the record it points at. When the card could read that record, its title links to the record's page in the current app, built by the same record-link builder the page's lookup values use; a record the reader cannot read is drawn with no link, and the card never says why. Nothing is authored for this: the referenceVia declaration on the field is the whole contract. List cells are not a call site yet.

When the platform deletes the record a pointer names, it can say so on the row. A pointer field that also declares referenceDeletedWhen: { field, value } names a sibling select field and the option the platform writes there, as sys_approval_request.record_id declares { field: 'cancel_reason', value: 'record_deleted' }. On a row holding that option the details grid draws a tombstone in the option's own label (localized when the console's bundle localizes it), reads nothing and links nothing. A record the card cannot read on any other row still gets the cause-free text: only the declaration means deleted.

Naming a registry item by name (position-ref, permission-ref)

A text field that stores the machine name of one item of a metadata registry — a position, a permission set — declares the matching widget, and the record form lists that registry instead of asking for a typed name:

{
  "position": {
    "type": "text",
    "label": "Position",
    "required": true,
    "maxLength": 100,
    "widget": "position-ref"
  }
}
Widget Lists Stores
position-ref the position registry (GET /api/v1/meta/position) the position's name
permission-ref the permission registry (GET /api/v1/meta/permission) the permission set's name

Like every widget value, the name is looked up as field:<widget>. Each item reads as its label beside its name, and the value written is the name alone: no label, no id. A stored name the registry does not list stays on screen, flagged not found, so a renamed or removed item is visible rather than dropped. position-ref leaves out the audience anchors, the spec's AUDIENCE_ANCHOR_POSITIONS (everyone, guest), because the server refuses an anchor as a grant target; a stored anchor still shows as its own option. The list comes from the data source's listMetadataItems(type). When the adapter has none, the list is empty, or the load fails, the field is a text box that takes the typed name; a failure is shown with its cause, and the box stays editable.

A widget's face on the record heading

A text field that declares widget: 'recipient-picker' or widget: 'object-ref' is drawn in a list column through the read cell registered under that widget's key, which names what the stored value references. When that field is also the object's nameField, the record page heading draws the value through the same cell: a record share heads its page with the recipient's name, not the user id it stores. Nothing is authored for this; the widget declaration on the field is the whole contract.

The heading lives in @object-ui/components, which this package depends on and so cannot be imported from here the other way round. @object-ui/components therefore owns a slot, setFieldReadFaceResolver / resolveFieldReadFace, and this package fills it when it loads with the lookup the list cells make. The widget's key draws the stored text until a host registers a face under it (the console registers its own), and while it does, the heading prints the stored value as before. So does a host that does not load @object-ui/fields.

Choosing a Field Type

Not sure which type fits your data? Follow the Field Type Decision Tree — a flowchart, quick-reference tables, and a use-case mapping for every type in this gallery.