Skip to content

Option Lists

An admin UI often needs to constrain a field to a set of allowed values (dropdowns, multi-selects). Configuard models this with option lists.

  • A row whose key starts with @ is an option-list definition, not a config value. Only its value matters, and it is always treated as a comma-separated list — regardless of type/listType.
  • Other rows point at it from their options field with a template: "${@UIColors}".
// @UIColors (csl) value: 'Blue,Red,Green,Amber' ← the list
// device.ui.accent (none) value: 'Amber', options: '${@UIColors}'

The field’s listType decides how many members its value may hold:

  • listType: none → the value must be one member of the list.
  • listType: csl / array → the value may contain several members.
  • A value outside the list throws during parseFlat().

Option-list rows are excluded from build() — they aren’t real config, so they never appear in .data. To resolve them, use parseFlat(), which extracts every @-key into a separate @ object (a trimmed, uncast string array) and expands each options reference into that array — exactly what an editor UI needs to render a control.

const { '@': optionLists, configList } = Configuard.parseFlat(rows);
optionLists;
// { UIColors: ['Blue', 'Red', 'Green', 'Amber'] }

See the Admin UI Workflow for the full round trip.