Skip to main content
The text field stores string values and supports validation through patterns, length constraints, and autogeneration capabilities. You can use it for simple text inputs, slugs, or as a primary key field.

Configuration options

int
default:"0"
Minimum required string characters. Set to 0 for no minimum limit.
int
default:"5000"
Maximum allowed string characters. Defaults to 5000 if not set.
string
Optional regex pattern to match against the field value. Leave empty to skip pattern validation.
string
Optional regex pattern used to generate random strings automatically on record create if no explicit value is set. The generated value must satisfy min, max, and pattern constraints.
bool
default:"false"
When true, requires the field value to be a non-empty string.
bool
default:"false"
Marks the field as the primary key. A collection can have only one primary key field, which must be named “id”.

Validation rules

The text field validates:
  • Length: Value must be between min and max characters (counting multi-byte characters as one)
  • Pattern: If specified, value must match the regex pattern
  • Required: If enabled, value cannot be empty
  • Primary key: Additional filesystem-safe character restrictions apply
When used as a primary key, the field has additional restrictions to ensure filesystem compatibility. Forbidden characters include: . / \ | " ' \ < > : ? * % $ \000 \t \n \r` and space.

Special setter modifiers

The text field supports the autogenerate modifier:

Go examples

Database column type

The text field creates different column types based on configuration:

Best practices

  • Use autogeneratePattern for fields like slugs that need unique identifiers
  • Test your regex patterns thoroughly to ensure they produce valid values
  • For primary keys, stick to URL-safe characters for better compatibility
  • Consider using reasonable max values to prevent database bloat

Zero value

The zero value for text fields is an empty string "".