API Reference

Props for the two components and the helpers exported by form-builder-types. * marks required props.

FormRenderer

From @/components/ui/rjsf-form-builder/form-renderer/form-renderer.

PropTypeDescription
schema*FormSchemaThe form definition to render.
locale*stringActive locale used to resolve LocalizedString values.
baseLocalestringFallback locale when a string has no translation for locale.
formDataRecord<string, unknown>Controlled form data. When omitted, the renderer keeps its own state.
onChange(data) => voidCalled on every change. Values of fields hidden by a condition are left out.
onSubmit(data) => voidCalled with valid data on submit. Hidden fields are left out here too. On multi-page forms, called from the last page after every page validates.
onError(errors) => voidCalled when submit (or Next) fails validation.
customValidateCustomValidatorExtra RJSF validation, run after validators registered with registerValidator. Those run automatically and need no prop.
themePartial<ThemeProps>Override individual widgets, fields or templates. Define it outside the component or wrap it in useMemo: a new object on every render remounts the form.
submitButtonReactNodeReplaces the default submit button. On multi-page forms it is shown on the last page, next to Back.
disabledbooleanDisables every input and the submit button.
classNamestringClass name for the wrapper element.

FormBuilder

From @/components/ui/rjsf-form-builder/form-builder/form-builder.

PropTypeDescription
locale*stringLocale used to display labels in the builder.
baseLocalestringFallback locale for display. New field and option labels are created under it (or under locale if omitted).
availableLocalesstring[]Locales shown as separate inputs when editing labels. Defaults to [locale].
initialSchemaFormSchemaStarting schema. Read once on mount.
onChange(schema: FormSchema) => voidCalled with the updated schema after every edit.
classNamestringClass name for the builder container. Give it a height.

Validation helpers

From @/lib/form-builder-types/validation.

FunctionTypeDescription
registerValidator(key, fn) => voidRegisters a named rule. fn(value, formData) returns an error message or undefined. Reference it from a field with validation.customRule.
unregisterValidator(key) => voidRemoves a registered rule.
createCustomValidator(schema) => CustomValidatorBuilds an RJSF validator that runs the registered rules for a schema. FormRenderer already does this.
import { registerValidator } from '@/lib/form-builder-types/validation';

registerValidator('work-email', (value) =>
  typeof value === 'string' && value.endsWith('@gmail.com')
    ? 'Please use a work email address.'
    : undefined,
);

// In the schema: { id: 'email', type: 'email', validation: { customRule: 'work-email' }, ... }

Schema helpers

From @/lib/form-builder-types/schema-builder, except localizeText, which is in @/lib/form-builder-types/i18n.

FunctionTypeDescription
toJsonSchema(schema, locale, baseLocale?) => RJSFSchemaConverts a FormSchema to JSON Schema, for using RJSF or a server-side validator directly.
toUiSchema(schema, locale, baseLocale?) => UiSchemaBuilds the matching RJSF uiSchema.
fieldKey(field) => stringThe property name a field's value is stored under: key, or id if there is no key.
splitIntoPages(fields) => FormPage[]Splits fields at each pagebreak. Each page has fields and the break's title/description. Empty pages are dropped.
evaluateCondition(condition, data) => booleanEvaluates a single field condition.
getVisibleFields(fields, data) => FormFieldDefinition[]Fields whose conditions pass. Chained conditions are resolved against visible fields only.
pruneHiddenData(fields, data) => Record<string, unknown>Returns data without the values of hidden fields, as passed to onSubmit.
localizeText(value, locale?, baseLocale?) => stringResolves a LocalizedString with the same fallback rules as the components.