CRUDUI

Home > @polyspec/crudui-validator

crudui-validator package

Classes

Class

Description

ComposeLoadError

Base class for every composition load failure. NOT a validation error.

FormInputError

Submitted form data whose shape does not match the specification.

Functions

Function

Description

hiddenPaths(spec, data)

The data paths of the fields whose design.show resolves to false against data (form-runtime.md, "Display"), as validation resolves them. The specification is composed without files, as the browser binding sends it.

validate(spec, data, options)

Validate data against a CRUDUI spec. The spec may carry $ref/$patch; they are expanded first via the compose pass. An unresolved composition throws ComposeLoadError (caller distinguishes a LOAD failure from valid:false).

validateDetail(spec, options)

Validate a detail specification's composition and forbidden-key structure.

validateList(spec, options)

Validate a CRUDUI list-spec STRUCTURE. The spec's columns map (and a { $ref, $patch } search overlay) may carry composition; it is expanded first via the compose pass — the SAME engine form-spec uses. An unresolved composition throws ComposeLoadError (caller distinguishes a LOAD failure from valid:false). A forbidden meta key anywhere in the composed list tree is likewise a LOAD failure. NO rows/data are validated (SPEC §9: rows are injected).

Interfaces

Interface

Description

BehaviorSlot

Common (all-type) behavior scripts (SPEC §4). Values are opaque client JS passed through verbatim and never routed through the expression engine. behavior: false nullifies composed inheritance.

ChoiceGroup

A group of choices in a choice list (docs/spec/schema.md, "Choice groups"). Only the choice list of a select field and the in rule accept groups; binding rejects a group in other fields.

ChoiceItem

One choice of a field's items (docs/spec/schema.md, "Choice appearance"). In a choice or multichoice field it may declare the appearance of its label and input; binding rejects these members in other fields.

ChoicePair

One choice of a choice list (docs/spec/schema.md, "Choice lists"). The option value is the canonical text of value; the list order is the display order for any values.

DesignNode

Per-node appearance: class/style for one DOM node. Both values are evaluated (expression or condition map) and yield strings.

DesignSlot

Appearance slot = visibility condition (show) + per-DOM-node appearance map (R8). class/style target the main (input) node; label/wrapper/group/ prepend target their respective nodes — which node a style targets is visible in the key.

FieldDesignSlot

The design slot of a form field: the design slot with declared attributes and a group's layout.

FieldSpec

CRUDUI field specification. Top level holds only first-class keys (SPEC §3 B): structure/identity, content, and the four role slots. All non-first-class detail is pushed under its dependency target (§3 C). A schema layer closes the top level (additionalProperties: false) and rejects every FORBIDDEN_META_KEYS entry here and one level below every slot/bucket.

FieldWrapperNode

The wrapper node of a form field: appearance and the attributes of the node root.

FileLoader

Loads a normalized file key to its parsed document. Throws ComposeLoadError('REF_FILE_NOT_FOUND') when the key is absent — the engine relies on that exact code (an unresolved $ref is a load error, never valid:true).

FormAction

Submission target of the form, kept unchanged in the template.

FormButton

One form button. A button or link needs text; a link needs href.

ItemsModel

Nested model descriptor of a dynamic source (items.model second shape): the source is a relational query, not a single model name, of the shape (model: { table, relations, keys }). Structure only — this fixes the declared shape of a query descriptor; building the query and running it is the runtime's job, out of scope here (SPEC §6 R1: types preserve, validation blocks; never model runtime resolution into the type).

ItemsSource

Dynamic option source (dependency isolation: dynamic items → items sub). Collects the source descriptor in one place.

STRUCTURE ONLY. This type fixes the declared shape of a dynamic source; it does NOT load options. The supported shape (type: search) is a model (a name string OR a nested { table, relations, keys } query) plus a sibling api_server (a runtime HTTP-endpoint function reference) plus a placeholder static items. None of model/api_server/items is resolved here — the runtime calls api_server, runs the model query, and replaces the placeholder. Runtime resolution is out of scope (SPEC §6 R1).

LangOverride

Per-language override map (one of the two lang.only shapes, SPEC §3 C): { ja: { validate: … }, en: { validate: … } }. The key is a language code, the value is the role-slot override (validate/design/behavior/options) applied to that language's input only. Distinct from the allowlist string[]: the allowlist restricts which languages render, the override map redefines slots per language.

LangSettings

Input multilingual settings object (kept under lang).

ListValidationResult

The result of checking a list or detail declaration: whether it is valid and its errors.

MessagesSpec

Custom error messages by registered rule name. Any other key fails the load with UNKNOWN_RULE.

MultipleDataSettings

Settings of rows that exist only in the data: the data keys are the rows and the form offers no row controls; only title, header and keys accompany only: true.

MultipleRowSettings

Settings of rows that the form adds, removes, copies and moves.

OptionsSlot

Type-dependent settings (dependency isolation: type → options). Defined and validated by the field's type; the core does not interpret them, so a new widget leaves the core unchanged. Container-type chrome and type-dependent scripts/callbacks live here too. The listed keys are common examples; the index signature admits any type-specific key.

PatchDirective

Composition change directive ($patch). Deep paths map to values (set/replace); the resolution order is $ref → $patch → single spec → field layer.

PathContext

Context for path resolution

RangeFieldSpec

A range field (docs/spec/schema.md, Range fields): a number chosen on a slider whose bounds and increment are the literal range and step rules; the minimum is a multiple of the step.

ValidateDetailOptions

Options for a detail structure validation run.

ValidateListOptions

Options for a CRUDUI list validation run (mirrors ValidateOptions).

ValidateOptions

Options for a CRUDUI validation run.

ValidateSlot

Validation rules (SPEC §3 slots.validate). Each value may be an expression/condition map, expressing conditional validation without a separate key (e.g. required: '.subscribe', email: true) — the condition is the value's expression (G1), never a separate key.

The named members are every built-in rule, with the parameter shapes the meta-schema declares; false or null disables a rule. equalTo, containedIn, typeFrom, minFrom, maxFrom, notEqual, unique, enddate, reference, accept, match, pattern, in and conditionTree receive their parameter unchanged, so they take no condition map. No other rule name exists: the meta-schema rejects it and the runtime fails the load with UNKNOWN_RULE.

ValidationError

Single validation error

ValidationResult

The result of validating form data: whether it is valid, its errors and the data paths that design.show hides.

Type Aliases

Type Alias

Description

BehaviorEntry

A behavior entry: an opaque client-JS script string, or { script, label } where the action label sits adjacent (behavior.{action}.label).

ChoiceItems

The choices and groups of a field's items in list order.

ChoiceList

Choices in list order for any values.

ComposeErrorCode

Machine-readable load-error codes.

ConditionMap

Declaration-ordered condition map (expressions.md §8). Each key is an Expression (§2 grammar); keys are evaluated top-to-bottom and the value of the first truthy key is returned. If none match, the value of the true key (the always-true default) is used; if absent, null. The default key is always literal true — convention symbols such as _ are forbidden (R4).

The condition map is a thin wrapper that calls the engine repeatedly; it is not a separate parser.

DeclaredAttributes

Attributes a form field declares for an element: a data-* or aria-* name that crudui does not write, to a literal string value (docs/spec/schema.md, Declared attributes).

Evaluated

An evaluated value: either a single Expression or a ConditionMap. Used by design.show/design.class/design.style, conditional validate.*, etc. The call site fixes the expected result type (boolean for show, string for class/style, …).

Expression

A single restricted-DSL expression string (expressions.md §2): paths (./../*), comparisons, logic, in/not in, ternary ?:, parentheses, literals. No arithmetic, functions, methods, regex, or eval. A bare ternary "...?...:..." is the shorthand of a condition map (same semantics).

FileSet

Virtual files available to $ref resolution, indexed by reference key.

ItemLabel

A static option label (display only). A plain string or a per-language LangMap (G3 content translation); the option VALUE is the map key, the label is just for display, so the label never participates in membership. Empty label may be null (SPEC §2 G3).

ItemLabelMap

Static value→label map (SPEC §2 G3): the key is the option value (the membership target), the entry is its display label — a string or a LangMap, e.g. { "0": { ko: 'Off label', en: 'Off' }, "1": { ko: 'On label', en: 'On' } }. The label is display-only; a LangMap label is NOT a membership value.

Items

Option source: an array of labels whose indexes are the values, a choice list (ChoiceList), a static value→label map (ItemLabelMap) or a dynamic ItemsSource (docs/spec/schema.md, "Languages and choices").

Lang

Input multilingual settings (dependency isolation: lang-dependent → lang sub). true is the bare default. An object carries the dimension settings, including the language-group chrome (frame/title/group_class).

LangMap

Multilingual content map (G3 content translation): a value translated per language by the spec author, e.g. { ko: 'Email label', en: 'Email' }. Distinct from lang (G3 input multilingualism, a structural dimension). An empty language slot may be null (no value — identical to absent; no render/validate effect, SPEC §2 G3).

LangOverrideMap

Per-language overrides indexed by language code.

LoadedDoc

A loaded YAML document (a parsed object tree).

LocalizedText

Field content text that may be a plain string or a per-language LangMap (G3). Empty content is omitted or null — null is identical to absent and has no render/validate effect (SPEC §2 G3).

Multiple

Repeated-row settings (dependency isolation: multiple-dependent → multiple sub). true is the bare default (repetition on, no settings); only, the same as { only: true }, declares rows that exist only in the data; an object carries the repetition settings.

Row identity is not a multiple field. Repeated data is an object keyed by row identity, and object member order is row order; the specification has no hidden identity or order field (see docs/spec/form-runtime.md).

The named keys are the canonical dependency_buckets.multiple.keys (only/min/max/copy/sortable/title/controls/header/onclick/keys). Other spellings such as multiple_max, sortable* or add_buttons are not recognition keys (R2 anti-duplication, R4 no magic tokens).

MultipleSettings

Repeated-row settings object (kept under multiple): the settings of rows that the form adds and removes, or of rows that exist only in the data.

Properties

Child field map (group/object). A $ref/$patch composition entry may sit alongside named child fields; the parser expands composition first, then the field layer.

Reference

Composition reference: one file path, or a list of paths resolved in declaration order where a later path overrides an earlier one. A path may select a fragment of a file as (file.yml).key.

Slot

Polymorphic role-slot value (SPEC G2). false turns the slot off (and nullifies composed inheritance); true is the shorthand for {} (default on); an object carries the slot's settings.

StaticItem

A label of an array whose indexes are the values.