Skip to main content
Fields define the structure and validation rules for data in your PocketBase collections. Each field type is optimized for specific data formats and use cases.

Common field properties

All field types share these core properties:

Additional common properties

Most fields also support:
  • Presentable - Hints the dashboard to use this field in record previews
  • Required - Makes the field value mandatory (non-empty)
Field IDs are automatically generated when you add fields to a collection. They ensure stability even if you rename the field.

Text field

Stores string values with optional validation constraints.

Properties

  • Min - Minimum character length (0 = no limit)
  • Max - Maximum character length (0 = default 5000)
  • Pattern - Regular expression for validation
  • AutogeneratePattern - Regex pattern for generating random values
  • PrimaryKey - Mark as collection primary key (only for id field)

Special modifiers

Examples

Number field

Stores numeric values (stored as float64 internally).

Properties

  • Min - Minimum value (nil = no limit)
  • Max - Maximum value (nil = no limit)
  • OnlyInt - Restrict to integer values only
  • Required - Require non-zero value

Special modifiers

Examples

Email field

Stores and validates email addresses.

Properties

  • OnlyDomains - Whitelist of allowed email domains
  • ExceptDomains - Blacklist of forbidden email domains
  • Required - Require non-empty email
You can only use either OnlyDomains or ExceptDomains, not both.

Examples

URL field

Stores and validates URLs.

Properties

  • OnlyDomains - Whitelist of allowed domains
  • ExceptDomains - Blacklist of forbidden domains
  • Required - Require non-empty URL

Bool field

Stores true/false values.

Properties

Only the common properties (Name, Required is not applicable as false is a valid value).

Date field

Stores date and time values.

Properties

  • Min - Minimum date (RFC 3339 format)
  • Max - Maximum date (RFC 3339 format)
  • Required - Require non-empty date

Autodate field

Automatically sets date on create and/or update.

Properties

  • OnCreate - Set date when record is created
  • OnUpdate - Update date when record is modified

Examples

Select field

Stores single or multiple predefined values.

Properties

  • Values - List of allowed values
  • MaxSelect - Max selections (1 = single, >1 = multiple)
  • Required - Require at least one selection

Examples

JSON field

Stores arbitrary JSON data.

Properties

  • MaxSize - Maximum JSON size in bytes (default 2MB)
  • Required - Require non-empty JSON

Example

Editor field

Stores rich text HTML content.

Properties

  • ConvertURLs - Auto-convert plain text URLs to links
  • OnlyDomains - Whitelist of allowed domains in content
  • ExceptDomains - Blacklist of forbidden domains
  • Required - Require non-empty content

File field

Handles file uploads with validation.

Properties

  • MaxSelect - Max files (1 = single, >1 = multiple)
  • MaxSize - Max size per file in bytes (default 5MB)
  • MimeTypes - Allowed MIME types (empty = all)
  • Thumbs - Thumbnail sizes for images
  • Protected - Require token to access files
  • Required - Require at least one file

Thumbnail formats

  • 100x300 - Crop to 100x300 from center
  • 100x300t - Crop to 100x300 from top
  • 100x300b - Crop to 100x300 from bottom
  • 100x300f - Fit inside 100x300 (no crop)
  • 0x300 - Resize to 300px height, preserve aspect ratio
  • 100x0 - Resize to 100px width, preserve aspect ratio

Special modifiers

Examples

Relation field

Links to records in other collections.

Properties

  • CollectionId - ID of the related collection (required)
  • MaxSelect - Max related records (1 = single, >1 = multiple)
  • MinSelect - Min required relations
  • CascadeDelete - Delete record if all relations are deleted
  • Required - Require at least one relation
CollectionId cannot be changed after the field is created. You must delete and recreate the field to change the target collection.

Special modifiers

Examples

Password field

Stores hashed passwords (auth collections only).

Properties

  • Min - Minimum password length
  • Max - Maximum password length
  • Pattern - Regex pattern for validation
  • Required - Require non-empty password
Passwords are automatically hashed using bcrypt before storage. The plain text password is never stored.

Working with fields

Adding fields to collections

Adding at specific position

Removing fields

Getting fields

Field validation

Fields are validated when you save the collection:

Helper functions

Common helper functions for working with field values:

Best practices

  • Set appropriate min/max constraints
  • Use patterns for format validation
  • Mark fields as required only when necessary
  • Provide sensible default values

Next steps

Base collections

Create your first collection

Auth collections

Add user authentication

Validation

Advanced validation techniques

API rules

Secure your data