Value types (ValueType)
Generated from the doc schema (CatalogDocSchema, @canonify/kernel-catalog/doc): each field’s type, default and description are the schema’s own, and each example is a bundle file that readBundle decodes. A field’s Example is its value in one of those examples.
ValueType
What a stored property holds.
One of, told apart by t:
- ValueType.text
- ValueType.integer
- ValueType.decimal
- ValueType.quantity
- ValueType.money
- ValueType.boolean
- ValueType.date
- ValueType.time
- ValueType.instant
- ValueType.duration
- ValueType.set
- ValueType.file
- ValueType.json
- EnumType
ValueType.text
Text (stored NFC; blank after trim is no value).
| Field | Type | Required | Default | Example | Description |
|---|---|---|---|---|---|
t |
"text" |
yes | — | "text" |
The value kind: text. |
format |
"line" | "long" | "email" | "phone" | "url" | "currency" |
no | — | "long" |
How the text is read and checked: one line (default), long text, an email address, a phone number, an http(s) URL or an ISO 4217 currency code. |
maxLength |
integer (greater than 0) | no | — | 254 |
At most this many characters (code points). |
The type of a stored property (an item of properties in types/<name>.json).
{ "t": "text", "format": "email", "maxLength": 254 }
ValueType.integer
A whole number, |v| ≤ 2^53−1.
| Field | Type | Required | Default | Example | Description |
|---|---|---|---|---|---|
t |
"integer" |
yes | — | "integer" |
The value kind: integer. |
The type of a stored property (an item of properties in types/<name>.json).
{ "t": "integer" }
ValueType.decimal
An exact decimal with a fixed number of fraction digits.
| Field | Type | Required | Default | Example | Description |
|---|---|---|---|---|---|
t |
"decimal" |
yes | — | "decimal" |
The value kind: decimal. |
scale |
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
yes | — | 2 |
Digits after the decimal point, 0–9; the value is stored as value × 10^scale. |
The type of a stored property (an item of properties in types/<name>.json).
{ "t": "decimal", "scale": 2 }
ValueType.quantity
An exact decimal amount of a unit.
| Field | Type | Required | Default | Example | Description |
|---|---|---|---|---|---|
t |
"quantity" |
yes | — | "quantity" |
The value kind: quantity. |
unit |
string | yes | — | "h" |
The unit code: a UNITS row (percent among them) or a unit the org declares in settings.units. |
scale |
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
yes | — | 1 |
Digits after the decimal point, 0–9; the value is stored as value × 10^scale. |
The type of a stored property (an item of properties in types/<name>.json).
{ "t": "quantity", "unit": "h", "scale": 1 }
ValueType.money
An amount of money in integer minor units of its currency.
| Field | Type | Required | Default | Example | Description |
|---|---|---|---|---|---|
t |
"money" |
yes | — | "money" |
The value kind: money. |
currency |
ValueType.money.currency | yes | — | "DKK" |
The currency: a fixed code or a property path; mandatory, there is no default currency (C23). |
The type of a stored property (an item of properties in types/<name>.json).
{ "t": "money", "currency": "DKK" }
The type of a stored property (an item of properties in types/<name>.json).
{ "t": "money", "currency": { "fromProp": ["pr_6w8y0a2c4e"] } }
ValueType.money.currency
The currency: a fixed code or a property path; mandatory, there is no default currency (C23).
One of:
ValueType.money.currency.fromProp
The currency read from another property of the row or of a required parent.
| Field | Type | Required | Default | Example | Description |
|---|---|---|---|---|---|
fromProp |
PropPath | yes | — | ["pr_6w8y0a2c4e"] |
A path of property ids along required to-one refs, ending at a required text{format:currency} property (C23). |
ValueType.boolean
True or false.
| Field | Type | Required | Default | Example | Description |
|---|---|---|---|---|---|
t |
"boolean" |
yes | — | "boolean" |
The value kind: boolean. |
The type of a stored property (an item of properties in types/<name>.json).
{ "t": "boolean" }
ValueType.date
A calendar date, YYYY-MM-DD.
| Field | Type | Required | Default | Example | Description |
|---|---|---|---|---|---|
t |
"date" |
yes | — | "date" |
The value kind: date. |
The type of a stored property (an item of properties in types/<name>.json).
{ "t": "date" }
ValueType.time
A time of day, HH:MM (C19).
| Field | Type | Required | Default | Example | Description |
|---|---|---|---|---|---|
t |
"time" |
yes | — | "time" |
The value kind: time. |
The type of a stored property (an item of properties in types/<name>.json).
{ "t": "time" }
ValueType.instant
A point in time, YYYY-MM-DDTHH:MM:SS.sssZ.
| Field | Type | Required | Default | Example | Description |
|---|---|---|---|---|---|
t |
"instant" |
yes | — | "instant" |
The value kind: instant. |
The type of a stored property (an item of properties in types/<name>.json).
{ "t": "instant" }
ValueType.duration
A length of time in integer milliseconds (C18).
| Field | Type | Required | Default | Example | Description |
|---|---|---|---|---|---|
t |
"duration" |
yes | — | "duration" |
The value kind: duration. |
The type of a stored property (an item of properties in types/<name>.json).
{ "t": "duration" }
ValueType.set
Any number of distinct values from a declared list, or of a shared enum domain.
| Field | Type | Required | Default | Example | Description |
|---|---|---|---|---|---|
t |
"set" |
yes | — | "set" |
The value kind: set. |
of |
ValueType.set.of | yes | — | (see the example) | The values the set may hold: a declared list, or a shared enum domain’s. |
The type of a stored property (an item of properties in types/<name>.json).
{
"t": "set",
"of": {
"values": [
{ "code": "low", "label": "Low" },
{ "code": "high", "label": "High" }
],
"ordered": false
}
}
The type of a stored property (an item of properties in types/<name>.json).
{ "t": "set", "of": { "enum": "en_4p8s2w6y0b" } }
The type of a stored property (an item of properties in types/<name>.json).
{ "t": "set", "of": { "enum": "en_4p8s2w6y0b", "only": ["ev_8n3q5s7u9w"] } }
ValueType.set.of
The values the set may hold: a declared list, or a shared enum domain’s.
One of:
ValueType.set.of.values
The values the set may hold.
| Field | Type | Required | Default | Example | Description |
|---|---|---|---|---|---|
values |
EnumValue[] | yes | — | (see the example) | The declared values, in their order. |
ordered |
boolean | no | — | false |
Whether the declared order is a ranking (comparisons and sorting follow it). |
ValueType.set.of.enum
The shared enum domain the set holds values of (or the subset only lists).
| Field | Type | Required | Default | Example | Description |
|---|---|---|---|---|---|
enum |
EnumId | yes | — | "en_4p8s2w6y0b" |
The shared enum domain whose values it holds (an EnumDecl of the doc’s enums; tick lj5). |
only |
EnumValueId[] (at least one) | no | — | ["ev_8n3q5s7u9w"] |
The values of the domain it allows, by id (a draft may write their codes): a sub-domain; left out, every value (tick 0tb). |
ValueType.file
A stored file, by its id.
| Field | Type | Required | Default | Example | Description |
|---|---|---|---|---|---|
t |
"file" |
yes | — | "file" |
The value kind: file. |
accept |
string[] | no | — | ["application/pdf"] |
The accepted media types: each an exact type (e.g. image/png) or type/* (any subtype of one top-level type, e.g. image/*). No other wildcard. |
maxBytes |
integer (greater than 0) | no | — | 10485760 |
The largest file accepted, in bytes. |
The type of a stored property (an item of properties in types/<name>.json).
{ "t": "file", "accept": ["application/pdf"], "maxBytes": 10485760 }
ValueType.json
A JSON value of a declared shape.
| Field | Type | Required | Default | Example | Description |
|---|---|---|---|---|---|
t |
"json" |
yes | — | "json" |
The value kind: json. |
schema |
JsonShape | yes | — | (see the example) | The shape the value must have. |
The type of a stored property (an item of properties in types/<name>.json).
{
"t": "json",
"schema": {
"type": "object",
"props": { "sku": { "type": "string" } },
"required": ["sku"]
}
}
EnumType
One of a declared list of values, or of a shared enum domain’s.
One of:
EnumType.values
One of a declared list of values.
| Field | Type | Required | Default | Example | Description |
|---|---|---|---|---|---|
t |
"enum" |
yes | — | "enum" |
The value kind: enum. |
values |
EnumValue[] | yes | — | (see the example) | The declared values, in their order. |
ordered |
boolean | no | — | true |
Whether the declared order is a ranking (comparisons and sorting follow it). |
The type of a stored enum property (an item of properties in types/<name>.json).
{
"t": "enum",
"values": [
{ "code": "low", "label": "Low" },
{ "code": "high", "label": "High" }
],
"ordered": true
}
EnumType.enum
One of the values of a shared enum domain (or of the subset only lists).
| Field | Type | Required | Default | Example | Description |
|---|---|---|---|---|---|
t |
"enum" |
yes | — | "enum" |
The value kind: enum. |
enum |
EnumId | yes | — | "en_4p8s2w6y0b" |
The shared enum domain whose values it holds (an EnumDecl of the doc’s enums; tick lj5). |
only |
EnumValueId[] (at least one) | no | — | ["ev_8n3q5s7u9w","ev_1b3d5f7h9k"] |
The values of the domain it allows, by id (a draft may write their codes): a sub-domain; left out, every value (tick 0tb). |
The type of a stored enum property (an item of properties in types/<name>.json).
{ "t": "enum", "enum": "en_4p8s2w6y0b" }
The type of a stored enum property (an item of properties in types/<name>.json).
{
"t": "enum",
"enum": "en_4p8s2w6y0b",
"only": ["ev_8n3q5s7u9w", "ev_1b3d5f7h9k"]
}
EnumValue
One declared value of an enum or set.
| Field | Type | Required | Default | Example | Description |
|---|---|---|---|---|---|
id |
EnumValueId | yes (propose assigns it; a new declaration leaves it out) | — | — | An enum value id (ev_…); renames keep it. |
code |
Ident | yes | — | "low" |
The code stored in the column and accepted as input. |
label |
Text | yes (a draft may leave it out: propose writes a default made from the name, catalog.label_defaulted) |
— | "Low" |
The words shown for this value. |
meaning |
ValueMeaning | no | — | "critical" |
What the value means (a band value: critical, warn or good). |
color |
EnumColorToken | no | — | "hot" |
The tone its chip is shown in. |
An item of values in an enum or set value type.
{ "code": "gold", "label": "Gold" }
An item of values in an enum or set value type.
{ "code": "overdue", "label": "Overdue", "meaning": "critical", "color": "hot" }
JsonShape
The closed JSON shape a json value is validated against.
One of, told apart by type:
JsonShape.string
A JSON scalar.
| Field | Type | Required | Default | Example | Description |
|---|---|---|---|---|---|
type |
"string" | "number" | "integer" | "boolean" | "null" |
yes | — | "string" |
A JSON scalar type. |
The schema of a json value type.
{ "type": "string" }
JsonShape.enum
A string from a fixed list.
| Field | Type | Required | Default | Example | Description |
|---|---|---|---|---|---|
type |
"enum" |
yes | — | "enum" |
One of a list of strings. |
values |
string[] | yes | — | ["small","large"] |
The strings the value may be. |
The schema of a json value type.
{ "type": "enum", "values": ["small", "large"] }
JsonShape.array
A JSON array of one item shape.
| Field | Type | Required | Default | Example | Description |
|---|---|---|---|---|---|
type |
"array" |
yes | — | "array" |
A JSON array. |
items |
JsonShape | yes | — | {"type":"string"} |
The shape of every item. |
maxItems |
integer (greater than 0) | no | — | 10 |
At most this many items. |
The schema of a json value type.
{ "type": "array", "items": { "type": "string" }, "maxItems": 10 }
JsonShape.object
A JSON object with a closed set of keys.
| Field | Type | Required | Default | Example | Description |
|---|---|---|---|---|---|
type |
"object" |
yes | — | "object" |
A JSON object. |
props |
Record<string, JsonShape> | yes | — | {"sku":{"type":"string"}} |
The shape of each allowed key; other keys are refused. |
required |
string[] | no | — | ["sku"] |
The keys that must be present. |
The schema of a json value type.
{
"type": "object",
"props": { "sku": { "type": "string" }, "qty": { "type": "integer" } },
"required": ["sku"]
}
JsonShape.any
Any JSON value.
| Field | Type | Required | Default | Example | Description |
|---|---|---|---|---|---|
type |
"any" |
yes | — | "any" |
Any JSON value (compile warns: value.json_untyped). |
The schema of a json value type.
{ "type": "any" }
ValueMeaning
What the value means: live, terminal-good, terminal-bad or sink for a state; critical, warn or good for a band.
Type: "live" | "terminal-good" | "terminal-bad" | "sink" | "critical" | "warn" | "good".
EnumColorToken
The tone the value is shown in: hot, warm, cool, good, info or neutral.
Type: "hot" | "warm" | "cool" | "good" | "info" | "neutral".