Schema Spec

A brij form is defined entirely by a JSON schema your server returns at GET /brij/schema/:slug. brij.js fetches this at open() time - no build step, no client-side config.

BrijSchema

The top-level schema object.

interface BrijSchema {
  title?: string
  description?: string
  submitLabel?: string
  steps: BrijStepSchema[]
}
PropertyTypeDescription
titlestringDisplayed in the form header. Defaults to 'Complete the form'.
descriptionstringSubtitle below the title.
submitLabelstringText on the submit button. Defaults to 'Submit'.
stepsBrijStepSchema[]One or more steps. Required - must have at least one.

BrijStepSchema

Each element in steps.

interface BrijStepSchema {
  id?: string
  title?: string
  description?: string
  fields: BrijFieldSchema[]
}
PropertyTypeDescription
idstringOptional identifier for the step. Not displayed.
titlestringDisplayed as the step heading. Defaults to 'Step N'.
descriptionstringDisplayed below the step heading.
fieldsBrijFieldSchema[]Fields rendered in this step.

BrijFieldSchema

Defines a single input field.

interface BrijFieldSchema {
  name: string
  label: string
  type: BrijFieldType
  placeholder?: string
  description?: string
  options?: BrijFieldOption[]
  validation?: BrijFieldValidation
  defaultValue?: string | boolean | string[]
}
PropertyTypeDescription
namestringHTML name attribute. Must be unique within the schema. Submitted as the form field key.
labelstringDisplayed above the input.
typeBrijFieldTypeInput type - see Field Types below.
placeholderstringInput placeholder text. For select, becomes the empty option label.
descriptionstringHelp text rendered below the input.
optionsBrijFieldOption[]Required for select, radio, and multi-checkbox fields.
validationBrijFieldValidationClient-side validation rules - see Validation below.
defaultValuestring or boolean or string[]Pre-filled value when the form opens. Use an array for multi-checkbox defaults.

Field Types

TypeRenders asNotes
texttext inputGeneral text input.
emailemail inputBrowser email validation built in.
textareatextareaMulti-line text. Min-height 120px, resizable vertically.
selectdropdownRequires options.
radioradio groupSingle choice. Requires options.
checkboxcheckbox or checkbox groupWith options: multi-select group. Without: single boolean checkbox.

Example - radio group:

{
  "name": "plan",
  "label": "Plan",
  "type": "radio",
  "options": [
    { "label": "Starter",    "value": "starter" },
    { "label": "Pro",        "value": "pro" },
    { "label": "Enterprise", "value": "enterprise" }
  ]
}

Validation

interface BrijFieldValidation {
  required?: boolean
  minLength?: number
  maxLength?: number
  pattern?: string
  min?: number
  max?: number
}

Validation runs client-side when the user clicks Next or Submit. If any field fails, an error message is shown and the step does not advance.

RuleApplies toDescription
requiredallField must have a non-empty value.
minLengthtext, email, textareaMinimum character count.
maxLengthtext, email, textareaMaximum character count.
patterntext, email, textareaJavaScript regex string. Matched with new RegExp(pattern).
mintext, emailNumeric minimum (value cast to number).
maxtext, emailNumeric maximum.

BrijFieldOption

Used by select, radio, and multi-checkbox fields.

interface BrijFieldOption {
  label: string
  value: string
}

value is what gets submitted. label is what the user sees.

Full example

A two-step form with a variety of field types:

{
  "title": "Team Signup",
  "description": "Tell us a bit about your team.",
  "submitLabel": "Create account",
  "steps": [
    {
      "title": "About you",
      "fields": [
        {
          "name": "name",
          "label": "Full name",
          "type": "text",
          "validation": { "required": true }
        },
        {
          "name": "email",
          "label": "Work email",
          "type": "email",
          "validation": { "required": true }
        }
      ]
    },
    {
      "title": "Your team",
      "fields": [
        {
          "name": "team_size",
          "label": "Team size",
          "type": "radio",
          "options": [
            { "label": "Just me",  "value": "1" },
            { "label": "2-10",     "value": "2-10" },
            { "label": "11-50",    "value": "11-50" },
            { "label": "50+",      "value": "50+" }
          ],
          "validation": { "required": true }
        },
        {
          "name": "use_cases",
          "label": "What will you use brij for?",
          "type": "checkbox",
          "options": [
            { "label": "Lead capture",   "value": "leads" },
            { "label": "Onboarding",     "value": "onboarding" },
            { "label": "Support intake", "value": "support" }
          ]
        },
        {
          "name": "notes",
          "label": "Anything else?",
          "type": "textarea",
          "placeholder": "Optional"
        }
      ]
    }
  ]
}