Schema Reference

Complete reference for all TypeScript types exported by form-builder-types.

FormSchema

The root object passed to FormRenderer and emitted by FormBuilder.

FieldTypeRequiredDescription
idstringYesUnique identifier for the form.
titleLocalizedStringYesForm heading, displayed above the fields.
descriptionLocalizedStringNoOptional subtitle shown below the title.
fieldsFormFieldDefinition[]YesOrdered list of field definitions. Rendered in ascending order value.
submitLabelLocalizedStringNoSubmit button label. Defaults to "Submit".
settingsFormSchemaSettingsNoLayout and behavior overrides.

FormFieldDefinition

Defines a single field in the form. Each entry in FormSchema.fields conforms to this type.

FieldTypeRequiredDescription
idstringYesUnique field key. Used as the form data key in the submitted object.
typeFormFieldTypeYesThe widget type. See Field Types below.
labelLocalizedStringYesVisible label for the field.
ordernumberYesSort order. Fields are rendered in ascending order.
placeholderLocalizedStringNoInput placeholder text. Applies to text, email, tel, number, textarea.
descriptionLocalizedStringNoHelper text shown below the input.
requiredbooleanNoMarks the field as required. Adds JSON Schema required constraint.
defaultValueunknownNoInitial value pre-filled in the form.
optionsFormFieldOption[]NoRequired for select and radio types.
validationFormFieldValidationNoValidation constraints. See Validation below.
conditionFormFieldConditionNoConditional display rule. Field is hidden unless the condition passes.

Field Types

All 13 supported field types, their JSON Schema mapping, and notes on behavior.

TypeWidgetJSON SchemaNotes
textInput (text)type: "string"General single-line text input.
numberInput (number)type: "number"Numeric input. Supports min/max validation.
emailInput (email)type: "string", format: "email"Validates email format automatically.
telInput (tel)type: "string"Phone number input with type="tel" for mobile keyboards.
selectSelect (dropdown)type: "string", enum: [...]Requires options. Uses shadcn Select component.
checkboxCheckboxtype: "boolean"Single boolean toggle. Submits true/false.
radioRadioGrouptype: "string", enum: [...]Requires options. Each option renders as a radio button.
dateInput (date)type: "string", format: "date"Native date picker. Submits ISO 8601 date string.
textareaTextareatype: "string"Multi-line text. Supports minLength/maxLength.
fileInput (file)type: "string", format: "data-url"File picker. Value is a base64 data URL.
headingh3 elementDisplay only. Does not collect data.
paragraphp elementDisplay only. Renders label as a paragraph.
separatorhr / SeparatorDisplay only. Visual divider between form sections.

Rows with a grey background are display-only fields — they are excluded from the submitted form data.

LocalizedString

LocalizedString is string | Record<string, string>. Use a plain string for single-language forms; use a locale map for multi-language forms.

// Plain string — always displayed as-is
label: "Full Name"

// Locale map — resolved at render time using the locale prop
label: { "en-US": "Full Name", "ko-KR": "이름", "ja-JP": "氏名" }

Resolution order: active locale baseLocale → first available key → empty string.

Validation

The validation field accepts a FormFieldValidation object.

FieldTypeApplies toDescription
minLengthnumbertext, email, tel, textareaMinimum character count.
maxLengthnumbertext, email, tel, textareaMaximum character count.
minnumbernumberMinimum numeric value.
maxnumbernumberMaximum numeric value.
patternstringtext, telRegex pattern the value must match.
customRulestringall input typesKey referencing a validator registered via registerValidator.

Custom validators

Register a validator once (at app startup) and reference it by key in any field's validation.customRule.

import { registerValidator, createCustomValidator } from '@/lib/form-builder-types/validation';

// Register once (e.g. in a layout or provider)
registerValidator('no-profanity', (value) => {
  if (typeof value === 'string' && value.includes('badword')) {
    return 'Please keep it respectful.';
  }
});

// Pass the validator to FormRenderer
<FormRenderer
  schema={schema}
  customValidate={createCustomValidator(schema)}
/>

Conditions

Set condition on a field to make it conditionally visible based on another field's current value.

// Show "otherDetails" only when "topic" equals "other"
{
  id: 'otherDetails',
  type: 'textarea',
  label: 'Please describe',
  order: 5,
  condition: {
    field: 'topic',   // the field id to watch
    operator: 'eq',
    value: 'other',
  }
}

Operators

OperatorDescriptionvalue required?
eqStrict equality (===)Yes
neqStrict inequality (!==)Yes
gtGreater than. Numeric comparison.Yes
ltLess than. Numeric comparison.Yes
containsString includes the value.Yes
emptyField value is empty, null, or undefined.No
notEmptyField value is not empty.No

Settings

FormSchemaSettings is an optional object on the root FormSchema.

FieldTypeDefaultDescription
layout"vertical" | "horizontal""vertical"Controls label position relative to the input.
showProgressBarbooleanfalseDisplays a progress bar indicating form completion percentage.
successMessageLocalizedStringMessage shown after successful submission (if provided).