---
title: Field
description: Field protocol schemas
---

{/* ⚠️  AUTO-GENERATED — DO NOT EDIT. Run build-docs.ts to regenerate. Hand-written docs go in content/docs/guides/. */}

Field Type Enum

<Callout type="info">
**Source:** `packages/spec/src/data/field.zod.ts`
</Callout>

## TypeScript Usage

```typescript
import { Address, ComputedFieldCache, CurrencyConfig, CurrencyValue, DataQualityRules, FieldType, FileAttachmentConfig, LocationCoordinates, SelectOption, VectorConfig } from '@objectstack/spec/data';
import type { Address, ComputedFieldCache, CurrencyConfig, CurrencyValue, DataQualityRules, 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 |


---

## FieldType

### Allowed Values

* `text`
* `textarea`
* `email`
* `url`
* `phone`
* `password`
* `secret`
* `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`
* `composite`
* `repeater`
* `record`
* `location`
* `address`
* `code`
* `json`
* `color`
* `rating`
* `slider`
* `signature`
* `qrcode`
* `progress`
* `tags`
* `vector`


---

## 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) |


---

