@sonata-innovations/fiber-shared
v1.2.1
Published
Shared condition and validation engines for the Fiber form builder system
Maintainers
Readme
@sonata-innovations/fiber-shared
The engine layer for Fiber — a system for building and rendering data-collection forms.
This package evaluates the logic embedded in a Flow: conditions, validation rules, inline markup, and calculation formulas. It is deliberately UI-free, so the same code runs in the browser (inside the render engine and the builder) and on a server. A rule that passes on the client passes on the server, by construction rather than by convention.
Install
npm install @sonata-innovations/fiber-sharedMost consumers never install this directly — it arrives as a dependency of fiber-fbre, fiber-fbt, and fiber-fbtl. Install it explicitly when you need to evaluate Fiber logic outside of rendering: server-side validation of a submission, a headless flow runner, or an analytics job over collected data.
Documentation
Full docs ship inside this package under docs/, so they always match the version you installed. Start with AGENTS.md at the package root, or read them online at github.com/sonata-innovations/fiber-docs.
The exact operator and validator lists, with their parameter shapes, are in the Flow schema reference.
What it provides
| Engine | What it does |
|---|---|
| Conditions | Evaluates a FlowConditionConfig — 19 operators, AND/OR logic — against collected values and external context |
| Validation | Evaluates a FlowValidationConfig — 17 validators, including cross-field matchesField — against a component value |
| Markup | Converts Fiber's inline markup ([b], [i], [l href="…"], [s size="…"]) to HTML |
| Formulas | Evaluates calculations: arithmetic, comparisons, IF(), and the SUM/COUNT/AVG/MIN/MAX aggregations over repeater iterations |
| References | resolvableReferences(flow) lists every ${...} a flow's markup can resolve — calculations, then fields, then host-supplied context keys, in the order the renderer resolves them |
Gotchas
- Formula references use single braces —
{component-uuid} + {other-uuid} * 0.1. Double braces do not parse. - Unfilled calculation dependencies default to
0, spreadsheet-style, rather than raising an error. patternvalidation rules takeparams.regex, notparams.pattern. Apatternkey is silently ignored and the rule always passes.- A validation rule with an empty-string
messagevalidates silently — it blocks progression without rendering an error. resolvableReferencesreturns entries in resolution order, not alphabetically. That order is the point: the first match a picker offers is the one that wins at render time. Display-only components are omitted —${a-heading-uuid}resolves to nothing.- This package is ESM with explicit
.jsimport extensions (NodeNext resolution), so it resolves under native Node ESM and server-side rendering.
Companion packages
| Package | What it is |
|---|---|
| @sonata-innovations/fiber-types | The schema these engines operate on |
| @sonata-innovations/fiber-fbre | Render engine — drives these engines client-side |
| @sonata-innovations/fiber-fbt | Full drag-and-drop builder |
| @sonata-innovations/fiber-fbtl | Lite builder for non-technical end users |
License
MIT
