My App

Checkbox Field

Boolean field for true/false values

The checkbox field provides a boolean input for true/false values. The SDK automatically handles common boolean representations and provides smart fixes for invalid values.

Basic Usage

{
  type: 'checkbox',
  label: 'Is Active',
  key: 'isActive',
  order: 0
}

Properties

Optional

Auto-Clean Options

Controls automatic data transformation on load and cell changes:

  • autoClean (false | object) - Controls automatic boolean conversion. Default: enabled with defaults below
    • Set to false to disable auto-cleaning (only smartFix suggestions will be available)
    • Set to object to customize conversion behavior

When autoClean is enabled (default), you can configure:

  • autoClean.truthy (string[]) - Values to convert to true. Default: ['true', 'yes', '1', '✓', '✔', 'on', 'y', 't']
  • autoClean.falsey (string[]) - Values to convert to false. Default: ['false', 'no', '0', '✗', '✘', 'off', 'n', 'f']

All comparisons are case-insensitive.

Note: SmartFix suggestions always use these same options, even if autoClean: false.

Other

  • defaultValue (boolean) - Default boolean value

Plus all common field properties.

Automatic Behavior

The SDK automatically:

  • Adds a boolean validator with autoFixOptions for smartFix suggestions
  • Adds a FormatBooleans transformer (unless autoClean: false) that runs on load and cell changes
  • Adds a default value of false if not specified

Boolean Conversion

When autoClean is enabled (default), the SDK recognizes these values as true:

  • 'true', 'yes', '1', '✓', '✔', 'on', 'y', 't'

And these values as false:

  • 'false', 'no', '0', '✗', '✘', 'off', 'n', 'f'

All comparisons are case-insensitive.

Use Cases

  • Active/inactive status
  • Yes/no questions
  • Feature flags, toggles
  • Consent, agreements
  • Conditional logic triggers

Examples

Basic with Defaults

{
  type: 'checkbox',
  label: 'Is Active',
  key: 'isActive',
  order: 0
}

Behavior:

  • Input: "yes" → Stored: true
  • Input: "no" → Stored: false
  • Input: "1" → Stored: true
  • Automatically converts common boolean representations

Custom Auto-Clean Options

{
  type: 'checkbox',
  label: 'Approved',
  key: 'approved',
  order: 0,
  autoClean: {
    truthy: ['approved', 'accept', 'ok', 'yes'],
    falsey: ['rejected', 'deny', 'no']
  }
}

Behavior:

  • Input: "approved" → Stored: true
  • Input: "rejected" → Stored: false
  • Input: "maybe" → Validation fails (not in truthy or falsey lists)

Disable Auto-Clean (Strict Mode)

{
  type: 'checkbox',
  label: 'Strict Boolean',
  key: 'strictBoolean',
  order: 0,
  autoClean: false
}

Behavior:

  • Input: "yes" → Validation fails (must be exactly true or false)
  • Input: true → Stored: true
  • Input: false → Stored: false
  • No automatic conversion, user must provide exact boolean values or use smartFix suggestions

Complete Example

import type { IvtSchema } from '@ivandt/importer';

const schema: IvtSchema = {
  title: 'User import',
  publicKey: 'pk_live_xxx',
  sessionToken: 'session_xxx',
  fields: [
    {
      type: 'checkbox',
      label: 'Is active',
      key: 'isActive',
      order: 0,
      defaultValue: true
    },
    {
      type: 'checkbox',
      label: 'Email verified',
      key: 'emailVerified',
      order: 1,
      validators: [
        { type: 'required' }
      ]
    },
    {
      type: 'checkbox',
      label: 'Marketing consent',
      key: 'marketingConsent',
      order: 2,
      description: 'User has agreed to receive marketing emails'
    }
  ]
};

Conditional Validation

Use the rules validator to make checkboxes required based on other field values:

{
  type: 'checkbox',
  label: 'Terms Accepted',
  key: 'termsAccepted',
  order: 0,
  validators: [
    {
      type: 'rules',
      effect: 'checked',
      rule: {
        all: [
          { field: 'accountType', operator: 'is equal', value: 'Premium' }
        ]
      },
      message: 'Premium accounts must accept terms'
    }
  ]
}

On this page