> For the complete documentation index, see [llms.txt](https://codemash.gitbook.io/codemash/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://codemash.gitbook.io/codemash/cloud/database/schema/field-types.md).

# Field type reference

Every field type a collection schema can declare — its data-schema shape, its widget, and what the server refuses — one page per type.

A schema field is exactly **one of 17 data types**. Each type has its own keywords, its own widget(s) in the record form, and its own refusals — the code and the sentence the server answers when a record breaks a rule. One page per type, all built from the gateway's contract and the generated all-types fixture (see the [Schema authoring guide](/codemash/cloud/database/schema.md#the-canonical-example)).

| Page                                                                                        | Data type                                    | Builder field           | Widget(s)                  | Stores                                           |
| ------------------------------------------------------------------------------------------- | -------------------------------------------- | ----------------------- | -------------------------- | ------------------------------------------------ |
| [Text](/codemash/cloud/database/schema/field-types/text.md)                                 | `string.schema.v1`                           | Text                    | `text`                     | a string                                         |
| [Long text and HTML](/codemash/cloud/database/schema/field-types/textarea-html.md)          | `string.schema.v1`                           | Long text, HTML         | `textarea`, `html`         | a string                                         |
| [Email](/codemash/cloud/database/schema/field-types/email.md)                               | `string.schema.v1` + `format: email`         | Email                   | `email`                    | a string                                         |
| [URI](/codemash/cloud/database/schema/field-types/uri.md)                                   | `string.schema.v1` + `format: uri`           | URI                     | `website`                  | a string                                         |
| [Translatable text](/codemash/cloud/database/schema/field-types/translatable.md)            | `string.schema.v1` + `meta.translateOptions` | Text → Translatable     | `text`, `textarea`, `html` | `{ "en": "…", "lt": "…" }`                       |
| [Integer](/codemash/cloud/database/schema/field-types/integer.md)                           | `integer.schema.v1`                          | Number                  | `number`                   | a whole number                                   |
| [Rating](/codemash/cloud/database/schema/field-types/rate.md)                               | `integer.schema.v1`                          | Rating                  | `rate`                     | a whole number                                   |
| [Decimal](/codemash/cloud/database/schema/field-types/decimal.md)                           | `decimal.schema.v1`                          | Number (decimal places) | `number`                   | a number                                         |
| [Currency](/codemash/cloud/database/schema/field-types/currency.md)                         | `currency.schema.v1`                         | Number → money          | `currency`                 | `{ "value": 9.99, "currency": "EUR" }`           |
| [Date and date-time](/codemash/cloud/database/schema/field-types/date.md)                   | `date.schema.v1`                             | Date, Date & time       | `date`, `datetime`         | unix epoch seconds                               |
| [Boolean](/codemash/cloud/database/schema/field-types/boolean.md)                           | `boolean.schema.v1`                          | Yes/No                  | `boolean`                  | `true` / `false`                                 |
| [Enum](/codemash/cloud/database/schema/field-types/enum.md)                                 | `enum.selection.schema.v1`                   | Select → Enumeration    | `select`                   | a value, or an array of values                   |
| [Tags](/codemash/cloud/database/schema/field-types/tags.md)                                 | `tags.schema.v1`                             | Tags                    | `tags`                     | an array of unique strings                       |
| [File](/codemash/cloud/database/schema/field-types/file.md)                                 | `file.schema.v1`                             | File                    | `file`                     | an array of file ids                             |
| [Geolocation](/codemash/cloud/database/schema/field-types/geolocation.md)                   | `geolocation.schema.v1`                      | Geo Location            | `geo_location`             | `{ "type": "Point", "coordinates": [lng, lat] }` |
| [JSON](/codemash/cloud/database/schema/field-types/json.md)                                 | `json.schema.v1`                             | JSON                    | `json`                     | any JSON object                                  |
| [User reference](/codemash/cloud/database/schema/field-types/user-reference.md)             | `user.selection.schema.v1`                   | Select → Users          | `select`                   | a user id, or an array                           |
| [Role reference](/codemash/cloud/database/schema/field-types/role-reference.md)             | `role.selection.schema.v1`                   | Select → Roles          | `select`                   | a role id, or an array                           |
| [Term reference](/codemash/cloud/database/schema/field-types/term-reference.md)             | `taxonomy.selection.schema.v1`               | Select → Taxonomy       | `select`                   | a term id, or an array                           |
| [Collection reference](/codemash/cloud/database/schema/field-types/collection-reference.md) | `collection.selection.schema.v1`             | Select → Collection     | `select`                   | a record id, or an array                         |
| [Nested form](/codemash/cloud/database/schema/field-types/nested-form.md)                   | `object.schema.v1`                           | Nested Form             | `nested_form`              | an object with declared members                  |
| [Array](/codemash/cloud/database/schema/field-types/array.md)                               | `array.schema.v1`                            | Array                   | `array`                    | a list of one item type                          |

Text, Long text, HTML, Email, URI and Translatable are one data type (`string.schema.v1`) with a different widget or keyword; Integer and Rating are one data type too. The `computational` widget (a read-only computed value) has no data type of its own.

## Keywords every type has

| Keyword                                                          | Where                                      | What it does                                                                                                         |
| ---------------------------------------------------------------- | ------------------------------------------ | -------------------------------------------------------------------------------------------------------------------- |
| `title`, `description`                                           | data schema, any field                     | free text about the field; the form label comes from the UI schema                                                   |
| `required`                                                       | data schema, the parent's list             | the field must be present and not `null` — `CM-ERRORS-DATABASE-030` `a value is required`                            |
| `default`                                                        | data schema, the primitives and selections | the value a new record gets when the field is left out; must obey the field's rules (`CM-ERRORS-SCHEMA-037` at save) |
| `unique`                                                         | data schema, text / integer / decimal      | no two records of the collection (per environment) share the value                                                   |
| `label`, `placeholder`, `help`, `required`, `readonly`, `hidden` | UI schema, every cell                      | the form hints; `help` is the text under the input — `watermark` and `hint` are refused                              |

## Error codes

Record writes are checked against the published schema. Each broken field answers one error with the code, `Field '<path>' is invalid: <reason>`, and a `Keyword` in its metadata. The path names nested values the way they sit in the record: `address.street`, `lines[0].qty`, `matrix[1][0]`.

| Code                     | Keyword            | When                                                                                                                                                    |
| ------------------------ | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `CM-ERRORS-DATABASE-030` | `required`         | a required value is missing or `null`                                                                                                                   |
| `CM-ERRORS-DATABASE-039` | `type`             | the wrong JSON type; a single value on a `multiple` field or the other way round; a dotted update through a field that has no members                   |
| `CM-ERRORS-DATABASE-040` | `length`           | `minLength` / `maxLength`, `minItems` / `maxItems`, a JSON field's `maxBytes`                                                                           |
| `CM-ERRORS-DATABASE-041` | `pattern`          | the string does not match the regular expression                                                                                                        |
| `CM-ERRORS-DATABASE-042` | `format`           | not an e-mail, a URI, a file id, a 3-letter currency code                                                                                               |
| `CM-ERRORS-DATABASE-043` | `range`            | `minimum` / `maximum` on integers, decimals, dates and currency amounts                                                                                 |
| `CM-ERRORS-DATABASE-044` | `multipleOf`       | the step of a decimal or a currency amount                                                                                                              |
| `CM-ERRORS-DATABASE-045` | `enum`             | a value outside the list: enum values, allowed currencies, allowed geometry types                                                                       |
| `CM-ERRORS-DATABASE-046` | `uniqueItems`      | a repeated entry in tags, a multiple enum, file ids, multiple references, an array with `uniqueItems`                                                   |
| `CM-ERRORS-DATABASE-047` | `properties`       | a missing or undeclared member of a currency, a geolocation or a nested form                                                                            |
| `CM-ERRORS-DATABASE-048` | `coordinates`      | not a `[longitude, latitude]` pair, or outside the world's range                                                                                        |
| `CM-ERRORS-DATABASE-049` | `translateOptions` | a translatable string that is not a language → text object                                                                                              |
| `CM-ERRORS-DATABASE-050` | `reference`        | the id is not a user of the project                                                                                                                     |
| `CM-ERRORS-DATABASE-051` | `reference`        | the id is not a role of the project (a role name is refused too)                                                                                        |
| `CM-ERRORS-DATABASE-052` | `reference`        | the id is not a term of the declared taxonomy in this environment                                                                                       |
| `CM-ERRORS-DATABASE-053` | `reference`        | the id is not a record of the declared collection in this environment                                                                                   |
| `CM-ERRORS-DATABASE-054` | `reference`        | the id is not a file in the storages the field allows                                                                                                   |
| `CM-ERRORS-DATABASE-055` | `reference`        | the declared target cannot be read at all in this environment (one error per field, not per id)                                                         |
| `CM-ERRORS-DATABASE-056` | —                  | a read with `expandReferences` by a caller who may not read one of the linked sources — see [References](/codemash/cloud/database/schema/references.md) |

A schema that breaks the contract is refused at **save** time with a `CM-ERRORS-SCHEMA-0xx` code — the list is on the [Schema authoring guide](/codemash/cloud/database/schema.md#common-refusals).

## The screens

The screenshots on the type pages are the record form of the generated all-types collection, one tab per family of types, as the Playwright suite captures them:

<figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-778f1601331ac885bd19ca53c1a48640c906a286%2Ffield-types-lists-1.png?alt=media" alt="Add New Record form of sc_e2e_all_types, Lists &#x26; files tab: tags inputs with a tag icon (Tags plain, type, unique, min items, max items, items, default) and file pickers with Pick a file and a search icon"><figcaption><p>The Lists &#x26; files tab of the all-types form — tags and file widgets.</p></figcaption></figure>

In the builder, each type is a card with its own icon; a nested form shows its field count and an array its item type:

<figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-80aa150a484e03a203f80090694c61bec2945e60%2Fnesting-builder-1.png?alt=media" alt="New schema sc_e2e_all_types in the Visual Builder, Nested tab: Object plain (1 field), Object type, Object properties, Object required as nested-form cards, Array items object (of Nested Form (1 fields)) and Array items array (of Array of Number)"><figcaption><p>The Nested tab of the all-types schema in the builder.</p></figcaption></figure>

## Related

[Schema authoring guide](/codemash/cloud/database/schema.md) · [References](/codemash/cloud/database/schema/references.md) · [Nested forms and arrays](/codemash/cloud/database/schema/nesting.md) · [Create a schema](/codemash/cloud/database/collections/create-schema.md) · [Add or edit a record](/codemash/cloud/database/collections/add-records.md)
