Skip to main content
The bool field stores a single true/false boolean value. It’s the simplest field type in PocketBase and is commonly used for flags, toggles, and yes/no options.

Configuration options

required
bool
default:"false"
When true, requires the field value to always be true. This is useful for acceptance checkboxes or required confirmations.

Validation rules

The bool field validates:
  • Type: Value must be a boolean (true or false)
  • Required: If enabled, value must be true
When required is true, the field will only accept true as a valid value. This is particularly useful for terms of service acceptance or similar use cases.

Go examples

import "github.com/pocketbase/pocketbase/core"

field := &core.BoolField{
    Name: "isActive",
}

collection.Fields.Add(field)

// Set field value
record.Set("isActive", true)

Database column type

BOOLEAN DEFAULT FALSE NOT NULL

API usage

When working with the PocketBase API, boolean fields accept various truthy/falsy values:
{
  "isActive": true,
  "isActive": "true",
  "isActive": 1,
  "isActive": "1"
}

Best practices

  • Use descriptive names that clearly indicate the boolean nature (e.g., isActive, hasAccess, enabled)
  • Consider using required: true for critical acknowledgments like terms of service
  • Default value is always false, so plan your logic accordingly
  • For tri-state logic (yes/no/unknown), consider using a select field instead

Zero value

The zero value for bool fields is false.

Build docs developers (and LLMs) love