> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/pocketbase/pocketbase/llms.txt
> Use this file to discover all available pages before exploring further.

# Bool field

> Store true/false boolean values

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

<ParamField path="required" type="bool" default="false">
  When true, requires the field value to always be `true`. This is useful for acceptance checkboxes or required confirmations.
</ParamField>

## Validation rules

The bool field validates:

* **Type**: Value must be a boolean (true or false)
* **Required**: If enabled, value must be `true`

<Info>
  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.
</Info>

## Go examples

<Tabs>
  <Tab title="Basic usage">
    ```go theme={null}
    import "github.com/pocketbase/pocketbase/core"

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

    collection.Fields.Add(field)

    // Set field value
    record.Set("isActive", true)
    ```
  </Tab>

  <Tab title="Required acceptance">
    ```go theme={null}
    field := &core.BoolField{
        Name:     "termsAccepted",
        Required: true, // Must be true
    }

    collection.Fields.Add(field)

    // This will validate successfully
    record.Set("termsAccepted", true)

    // This will fail validation
    record.Set("termsAccepted", false)
    ```
  </Tab>

  <Tab title="Feature flags">
    ```go theme={null}
    collection.Fields.Add(&core.BoolField{
        Name: "emailVerified",
    })

    collection.Fields.Add(&core.BoolField{
        Name: "isPremium",
    })

    collection.Fields.Add(&core.BoolField{
        Name: "notificationsEnabled",
    })

    // Set values
    record.Set("emailVerified", true)
    record.Set("isPremium", false)
    record.Set("notificationsEnabled", true)
    ```
  </Tab>
</Tabs>

## Database column type

```sql theme={null}
BOOLEAN DEFAULT FALSE NOT NULL
```

## API usage

When working with the PocketBase API, boolean fields accept various truthy/falsy values:

<CodeGroup>
  ```json Accepted true values theme={null}
  {
    "isActive": true,
    "isActive": "true",
    "isActive": 1,
    "isActive": "1"
  }
  ```

  ```json Accepted false values theme={null}
  {
    "isActive": false,
    "isActive": "false",
    "isActive": 0,
    "isActive": "0",
    "isActive": ""
  }
  ```
</CodeGroup>

## Best practices

<Note>
  * 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
</Note>

## Zero value

The zero value for bool fields is `false`.
