Schema reference¶
Every node in a schema is one of four kinds. This page documents each one and
all of its properties.
Each property is tagged with its concern:
data — shapes the control structure, the value, or its validation.
ui — shapes only the rendered presentation.
Tip
A property tagged data changes what form.getRawValue() returns or whether
the form is valid. A property tagged ui never changes the value — only how
it looks.
leaf — a single field¶
A scalar field. Builds a FormControl.
{ kind: 'leaf', type: 'string', name: 'firstName', label: 'First name', required: true }
Property |
Type |
Concern |
Description |
|---|---|---|---|
|
|
data |
Node discriminant. Required. |
|
|
data |
Field identity. Must equal this node’s key in the parent |
|
|
data |
The value type (see table below). Required. |
|
|
data |
Adds |
|
matches |
data |
Initial value when no value is supplied to |
|
|
ui |
Field label. Falls back to |
|
|
data |
Required when |
|
|
ui |
Display labels for the enum options, positionally aligned with |
type maps to a control value type:
|
Control value |
Rendered as |
|---|---|---|
|
|
text input |
|
|
number input |
|
|
checkbox |
|
|
select |
enumLabel alignment
enumLabel is a parallel array — enumLabel[i] labels enum[i]. Keep the two
arrays the same length and order. If you reorder enum, reorder enumLabel to
match.
leafList — a list of scalars¶
A repeatable scalar field. Builds a FormArray<FormControl>.
{ kind: 'leafList', type: 'string', name: 'tags', label: 'Tags' }
Property |
Type |
Concern |
Description |
|---|---|---|---|
|
|
data |
Node discriminant. Required. |
|
|
data |
Identity; must equal the |
|
|
data |
Element value type. Required. |
|
array of the element type |
data |
Initial items when no value is supplied. |
|
|
data |
Minimum item count. |
|
|
data |
Maximum item count. |
|
|
ui |
List label. Falls back to |
nodeGroup — a nested object¶
A group of fields. Builds a nested FormGroup. The root of every schema is a
nodeGroup.
{
kind: 'nodeGroup',
name: 'address',
label: 'Address',
children: {
street: { kind: 'leaf', type: 'string', name: 'street' },
city: { kind: 'leaf', type: 'string', name: 'city' },
},
}
Property |
Type |
Concern |
Description |
|---|---|---|---|
|
|
data |
Node discriminant. Required. |
|
|
data |
Identity; must equal the |
|
|
data |
The child nodes, keyed by field name. Required. |
|
|
ui |
Group heading (card or panel title). Falls back to |
|
|
ui |
Renders the group as the top-level accordion layout instead of a card. Set on the schema root. |
|
|
data |
Makes the group optional: rendered with an on/off toggle and absent from the form value until enabled. Its control is removed when off and rebuilt when on. |
|
|
ui |
Layout options (see below). |
Appearance¶
Property |
Type |
Concern |
Description |
|---|---|---|---|
|
|
ui |
Render the group’s fields inline, without a surrounding card. |
|
|
ui |
Render the group card without its border. |
nodeGroupList — a list of objects¶
A repeatable group. Builds a FormArray<FormGroup>. Each item is an instance of
the type group.
{
kind: 'nodeGroupList',
name: 'contacts',
label: 'Contacts',
minItems: 1,
type: {
kind: 'nodeGroup',
name: 'contact',
children: {
email: { kind: 'leaf', type: 'string', name: 'email' },
primary: { kind: 'leaf', type: 'boolean', name: 'primary' },
},
},
}
Property |
Type |
Concern |
Description |
|---|---|---|---|
|
|
data |
Node discriminant. Required. |
|
|
data |
Identity; must equal the |
|
|
data |
The group schema each item conforms to. Required. |
|
|
data |
Minimum item count; the last item cannot be removed below this. |
|
|
data |
Maximum item count. |
|
|
ui |
List label. Falls back to |
choice — a discriminated selection¶
The user picks one case; only that case’s fields are present. Rendered as a
case selector plus the selected case’s fields.
{
kind: 'choice',
name: 'transport',
cases: {
tcp: {
port: { kind: 'leaf', type: 'number', name: 'port' },
tls: { kind: 'leaf', type: 'boolean', name: 'tls' },
},
udp: {
port: { kind: 'leaf', type: 'number', name: 'port' },
},
},
}
Property |
Type |
Concern |
Description |
|---|---|---|---|
|
|
data |
Node discriminant. Required. |
|
|
data |
Identity; must equal the |
|
|
data |
Each case name → that case’s fields. Required. |
|
|
data |
Case selected when none is chosen. |
|
|
data |
Whether a case must be selected. |
|
|
ui |
Selector label. Falls back to |
In the form value a choice is { __case: <caseName>, ...that case's fields }.
Current limitations¶
The library is at an early version (0.1.x). A few properties are declared on the
model but not yet fully wired:
minItems/maxItemscurrently gate the remove control onnodeGroupList, but are not yet enforced asFormArrayvalidators, and are not yet applied toleafList. Treat them as UI hints for now, and validate cardinality yourself if it must be enforced.descriptionandsubTypeexist on the types but are not rendered. Avoid relying on them.
These are tracked for a future release; the source repository is the place to follow progress.