Reference

Schema

A schema is plain data: one form identifier, one or more ordered steps, and one or more fields per step.

Form schema

type FormSchema = {
  id: string;
  steps: FormStep[];
};

Identifiers must be non-empty and unique where applicable. Invalid schemas throw SchemaValidationError when the form is created.

Steps

type FormStep = {
  id: string;
  title: string;
  description?: string;
  fields: FormField[];
};

Step order controls forward and backward navigation. Demetria v0.1.1 does not support conditional or dynamically inserted steps.

Fields

Type Value Default Additional data
text string "" None
email string "" Email format validation
number number or empty string "" Must be finite when provided
textarea string "" None
select string "" Requires non-empty options
checkbox boolean false Required means checked

Every field has name, type, and label. It may also have description and required. Only required: true makes it mandatory.

{
  name: 'plan',
  type: 'select',
  label: 'Plan',
  required: true,
  options: [
    { value: 'starter', label: 'Starter' },
    { value: 'team', label: 'Team' }
  ]
}

Values and types

getValues() returns a detached, read-only FormValues snapshot. Its values are strings, numbers, or booleans. Field names remain runtime schema data.

const values = form.getValues();
console.log(values.fullName);

Current boundary: v0.1.1 does not derive a field-specific value type from a schema literal and does not provide custom validators.