Field Modifiers

Modifiers enrich the stored type selected by a primitive or structured builder. Every modifier returns the same chainable FieldBuilder.

const title = bd
  .text()
  .required()
  .indexed()
  .description('Customer-facing project title.')
  .helper('Use the title shown in the signed proposal.')

Schema modifiers

ModifierEffect
.required()Sets isRequired: true and isNullable: false
.optional()Sets isRequired: false and isNullable: true
.nullable(value?)Explicitly controls nullability; defaults to true
.default(value)Adds a default value
.indexed(value?)Requests an index; defaults to true
.unique(value?)Requests uniqueness; defaults to true
.description(text)Adds schema-facing documentation

.required() and .optional() are schema/nullability declarations. They are not the same operation as running validateFieldValue() against notNull.

Renderer metadata

ModifierEffect
.helper(text)Adds renderer-facing helper text
.formElement(type, metadata?)Chooses preferred input intent
.dynamicOptions(config)Describes an endpoint-backed choice source
const assignee = bd
  .text()
  .formElement('dropdown')
  .dynamicOptions({
    endpoint: '/api/team-members',
    method: 'GET',
    cachePolicy: 'stale-while-revalidate',
  })

The SDK stores the endpoint metadata but does not fetch choices during schema compilation. The renderer owns that request.

Validation modifiers

ModifierEffect
.validate(rules)Merges a ValidationRules object
.requiredIf(condition)Adds conditional presence metadata
.regex(pattern)Adds a string pattern rule
.check(sql)Stores validation.checkExpression

These are covered in Validation.

Storage and security intent

ModifierLocal metadata
.strategy(mode, tableName?)Emits flattened, jsonb, or separateTable storage intent
.encrypted()User-scoped encryption intent
.encryptedLight()Master-key encryption intent
.private()Private-field intent

strategy and separateTableName are emitted by toJSONSchema() in 0.9.50. Encryption and private-field metadata are still local-only; do not treat those security modifiers as end-to-end server enforcement until the receiving API carries them.

All RAW_JSON-backed object form elements can use .strategy('jsonb'), including object, address, measurement, availability, date range, geo, time slot, and structured date-time values. MultiPopulator uses the same strategy metadata when binding repeated entries to a JSONB field.

Relationship modifiers

.references(), .belongsToMany(), and .onDelete() operate on relation builders. They are covered after the core field topics in Relationships and Extensions.

Next: Validation.