Field
Field protocol schemas
Field Type Enum
Source: packages/spec/src/data/field.zod.ts
TypeScript Usage
import { Address, ComputedFieldCache, CurrencyConfig, CurrencyValue, DataQualityRules, Field, FieldType, FileAttachmentConfig, LocationCoordinates, SelectOption, VectorConfig } from '@objectstack/spec/data';
import type { Address, ComputedFieldCache, CurrencyConfig, CurrencyValue, DataQualityRules, Field, FieldType, FileAttachmentConfig, LocationCoordinates, SelectOption, VectorConfig } from '@objectstack/spec/data';
// Validate data
const result = Address.parse(data);Address
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| street | string | optional | Street address |
| city | string | optional | City name |
| state | string | optional | State/Province |
| postalCode | string | optional | Postal/ZIP code |
| country | string | optional | Country name or code |
| countryCode | string | optional | ISO country code (e.g., US, GB) |
| formatted | string | optional | Formatted address string |
ComputedFieldCache
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| enabled | boolean | ✅ | Enable caching for computed field results |
| ttl | number | ✅ | Cache TTL in seconds (0 = no expiration) |
| invalidateOn | string[] | ✅ | Field paths that invalidate cache (e.g., ["inventory.quantity", "pricing.base_price"]) |
CurrencyConfig
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| precision | integer | ✅ | Decimal precision (default: 2) |
| currencyMode | Enum<'dynamic' | 'fixed'> | ✅ | Currency mode: dynamic (user selectable) or fixed (single currency) |
| defaultCurrency | string | ✅ | Default or fixed currency code (ISO 4217, e.g., USD, CNY, EUR) |
CurrencyValue
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| value | number | ✅ | Monetary amount |
| currency | string | ✅ | Currency code (ISO 4217) |
DataQualityRules
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| uniqueness | boolean | ✅ | Enforce unique values across all records |
| completeness | number | ✅ | Minimum ratio of non-null values (0-1, default: 0 = no requirement) |
| accuracy | Object | optional | Accuracy validation configuration |
Field
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| name | string | optional | Machine name (snake_case) |
| label | string | optional | Human readable label |
| type | Enum<'text' | 'textarea' | 'email' | 'url' | 'phone' | 'password' | 'markdown' | 'html' | 'richtext' | 'number' | 'currency' | 'percent' | 'date' | 'datetime' | 'time' | 'boolean' | 'toggle' | 'select' | 'multiselect' | 'radio' | 'checkboxes' | 'lookup' | 'master_detail' | 'tree' | 'image' | 'file' | 'avatar' | 'video' | 'audio' | 'formula' | 'summary' | 'autonumber' | 'location' | 'address' | 'code' | 'json' | 'color' | 'rating' | 'slider' | 'signature' | 'qrcode' | 'progress' | 'tags' | 'vector'> | ✅ | Field Data Type |
| description | string | optional | Tooltip/Help text |
| format | string | optional | Format string (e.g. email, phone) |
| columnName | string | optional | Physical column name in the target datasource. Defaults to the field key when not set. |
| required | boolean | ✅ | Is required |
| searchable | boolean | ✅ | Is searchable |
| multiple | boolean | ✅ | Allow multiple values (Stores as Array/JSON). Applicable for select, lookup, file, image. |
| unique | boolean | ✅ | Is unique constraint |
| defaultValue | any | optional | Default value |
| maxLength | number | optional | Max character length |
| minLength | number | optional | Min character length |
| precision | number | optional | Total digits |
| scale | number | optional | Decimal places |
| min | number | optional | Minimum value |
| max | number | optional | Maximum value |
| options | Object[] | optional | Static options for select/multiselect |
| reference | string | optional | Target object name (snake_case) for lookup/master_detail fields. Required for relationship types. Used by $expand to resolve foreign key IDs into full objects. |
| referenceFilters | string[] | optional | Filters applied to lookup dialogs (e.g. "active = true") |
| writeRequiresMasterRead | boolean | optional | If true, user needs read access to master record to edit this field |
| deleteBehavior | Enum<'set_null' | 'cascade' | 'restrict'> | ✅ | What happens if referenced record is deleted |
| expression | string | optional | Formula expression |
| summaryOperations | Object | optional | Roll-up summary definition |
| language | string | optional | Programming language for syntax highlighting (e.g., javascript, python, sql) |
| theme | string | optional | Code editor theme (e.g., dark, light, monokai) |
| lineNumbers | boolean | optional | Show line numbers in code editor |
| maxRating | number | optional | Maximum rating value (default: 5) |
| allowHalf | boolean | optional | Allow half-star ratings |
| displayMap | boolean | optional | Display map widget for location field |
| allowGeocoding | boolean | optional | Allow address-to-coordinate conversion |
| addressFormat | Enum<'us' | 'uk' | 'international'> | optional | Address format template |
| colorFormat | Enum<'hex' | 'rgb' | 'rgba' | 'hsl'> | optional | Color value format |
| allowAlpha | boolean | optional | Allow transparency/alpha channel |
| presetColors | string[] | optional | Preset color options |
| step | number | optional | Step increment for slider (default: 1) |
| showValue | boolean | optional | Display current value on slider |
| marks | Record<string, string> | optional | Custom marks/labels at specific values (e.g., {0: "Low", 50: "Medium", 100: "High"}) |
| barcodeFormat | Enum<'qr' | 'ean13' | 'ean8' | 'code128' | 'code39' | 'upca' | 'upce'> | optional | Barcode format type |
| qrErrorCorrection | Enum<'L' | 'M' | 'Q' | 'H'> | optional | QR code error correction level (L=7%, M=15%, Q=25%, H=30%). Only applicable when barcodeFormat is "qr" |
| displayValue | boolean | optional | Display human-readable value below barcode/QR code |
| allowScanning | boolean | optional | Enable camera scanning for barcode/QR code input |
| currencyConfig | Object | optional | Configuration for currency field type |
| vectorConfig | Object | optional | Configuration for vector field type (AI/ML embeddings) |
| fileAttachmentConfig | Object | optional | Configuration for file and attachment field types |
| encryptionConfig | Object | optional | Field-level encryption configuration for sensitive data (GDPR/HIPAA/PCI-DSS) |
| maskingRule | Object | optional | Data masking rules for PII protection |
| auditTrail | boolean | ✅ | Enable detailed audit trail for this field (tracks all changes with user and timestamp) |
| dependencies | string[] | optional | Array of field names that this field depends on (for formulas, visibility rules, etc.) |
| cached | Object | optional | Caching configuration for computed/formula fields |
| dataQuality | Object | optional | Data quality validation and monitoring rules |
| group | string | optional | Field group name for organizing fields in forms and layouts (e.g., "contact_info", "billing", "system") |
| conditionalRequired | string | optional | Formula expression that makes this field required when TRUE (e.g., "status = 'closed_won'") |
| hidden | boolean | ✅ | Hidden from default UI |
| readonly | boolean | ✅ | Read-only in UI |
| sortable | boolean | ✅ | Whether field is sortable in list views |
| inlineHelpText | string | optional | Help text displayed below the field in forms |
| trackFeedHistory | boolean | optional | Track field changes in Chatter/activity feed (Salesforce pattern) |
| caseSensitive | boolean | optional | Whether text comparisons are case-sensitive |
| autonumberFormat | string | optional | Auto-number display format pattern (e.g., "CASE-{0000}") |
| index | boolean | ✅ | Create standard database index |
| externalId | boolean | ✅ | Is external ID for upsert operations |
FieldType
Allowed Values
texttextareaemailurlphonepasswordmarkdownhtmlrichtextnumbercurrencypercentdatedatetimetimebooleantoggleselectmultiselectradiocheckboxeslookupmaster_detailtreeimagefileavatarvideoaudioformulasummaryautonumberlocationaddresscodejsoncolorratingslidersignatureqrcodeprogresstagsvector
FileAttachmentConfig
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| minSize | number | optional | Minimum file size in bytes |
| maxSize | number | optional | Maximum file size in bytes (e.g., 10485760 = 10MB) |
| allowedTypes | string[] | optional | Allowed file extensions (e.g., [".pdf", ".docx", ".jpg"]) |
| blockedTypes | string[] | optional | Blocked file extensions (e.g., [".exe", ".bat", ".sh"]) |
| allowedMimeTypes | string[] | optional | Allowed MIME types (e.g., ["image/jpeg", "application/pdf"]) |
| blockedMimeTypes | string[] | optional | Blocked MIME types |
| virusScan | boolean | ✅ | Enable virus scanning for uploaded files |
| virusScanProvider | Enum<'clamav' | 'virustotal' | 'metadefender' | 'custom'> | optional | Virus scanning service provider |
| virusScanOnUpload | boolean | ✅ | Scan files immediately on upload |
| quarantineOnThreat | boolean | ✅ | Quarantine files if threat detected |
| storageProvider | string | optional | Object storage provider name (references ObjectStorageConfig) |
| storageBucket | string | optional | Target bucket name |
| storagePrefix | string | optional | Storage path prefix (e.g., "uploads/documents/") |
| imageValidation | Object | optional | Image-specific validation rules |
| allowMultiple | boolean | ✅ | Allow multiple file uploads (overrides field.multiple) |
| allowReplace | boolean | ✅ | Allow replacing existing files |
| allowDelete | boolean | ✅ | Allow deleting uploaded files |
| requireUpload | boolean | ✅ | Require at least one file when field is required |
| extractMetadata | boolean | ✅ | Extract file metadata (name, size, type, etc.) |
| extractText | boolean | ✅ | Extract text content from documents (OCR/parsing) |
| versioningEnabled | boolean | ✅ | Keep previous versions of replaced files |
| maxVersions | number | optional | Maximum number of versions to retain |
| publicRead | boolean | ✅ | Allow public read access to uploaded files |
| presignedUrlExpiry | number | ✅ | Presigned URL expiration in seconds (default: 1 hour) |
LocationCoordinates
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| latitude | number | ✅ | Latitude coordinate |
| longitude | number | ✅ | Longitude coordinate |
| altitude | number | optional | Altitude in meters |
| accuracy | number | optional | Accuracy in meters |
SelectOption
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| label | string | ✅ | Display label (human-readable, any case allowed) |
| value | string | ✅ | Stored value (lowercase machine identifier) |
| color | string | optional | Color code for badges/charts |
| default | boolean | optional | Is default option |
VectorConfig
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| dimensions | integer | ✅ | Vector dimensionality (e.g., 1536 for OpenAI embeddings) |
| distanceMetric | Enum<'cosine' | 'euclidean' | 'dotProduct' | 'manhattan'> | ✅ | Distance/similarity metric for vector search |
| normalized | boolean | ✅ | Whether vectors are normalized (unit length) |
| indexed | boolean | ✅ | Whether to create a vector index for fast similarity search |
| indexType | Enum<'hnsw' | 'ivfflat' | 'flat'> | optional | Vector index algorithm (HNSW for high accuracy, IVFFlat for large datasets) |