Field definitions for capturing user input
FormField is a union type representing all possible field types in a form. Each field type has a type discriminator and shares common base properties.
type FormField =
| TextField
| BooleanField
| NumberField
| CoordinateField
| BboxField
| MoneyField
| AddressField
| PhoneField
| DurationField
| EmailField
| UuidField
| UriField
| EnumField
| DateField
| DatetimeField
| TimeField
| PersonField
| OrganizationField
| IdentificationField
| MultiselectField
| PercentageField
| RatingField
| FieldsetField
BaseField
All field types share these base properties:
label?: string
Human-readable label for the field
description?: string
Long-form description or helper text displayed in the UI
required?: boolean | string
Whether this field is required. Can be a boolean or logic expression
visible?: boolean | string
Whether this field is visible. Can be a boolean or logic expression. Defaults to true
Field Types
Each field type includes all BaseField properties plus the type-specific properties listed below.
TextField
Text input field for string values.
type: 'text'
Discriminator for text field type
minLength?: number
Minimum character length
maxLength?: number
Maximum character length
pattern?: string
Regular expression pattern for validation
default?: string
Default value for the field
BooleanField
Boolean checkbox/toggle field.
type: 'boolean'
Discriminator for boolean field type
default?: boolean
Default value for the field
NumberField
Numeric input field.
type: 'number'
Discriminator for number field type
min?: number
Minimum allowed value
max?: number
Maximum allowed value
default?: number
Default value for the field
EnumField
Single-select dropdown field.
type: 'enum'
Discriminator for enum field type
enum: (string | number)[]
Available options for selection
default?: string | number
Default value for the field
MultiselectField
Multi-select field allowing multiple selections.
type: 'multiselect'
Discriminator for multiselect field type
enum: (string | number)[]
Available options for selection
min?: number
Minimum number of selections required
max?: number
Maximum number of selections allowed
default?: (string | number)[]
Default value for the field
DateField
Date input field (ISO 8601 format: YYYY-MM-DD).
type: 'date'
Discriminator for date field type
min?: string
Minimum allowed date in ISO 8601 format
max?: string
Maximum allowed date in ISO 8601 format
default?: string
Default value for the field
DatetimeField
Datetime input field (ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ).
type: 'datetime'
Discriminator for datetime field type
min?: string
Minimum allowed datetime in ISO 8601 format
max?: string
Maximum allowed datetime in ISO 8601 format
default?: string
Default value for the field
TimeField
Time input field (HH:MM:SS format).
type: 'time'
Discriminator for time field type
min?: string
Minimum allowed time
max?: string
Maximum allowed time
default?: string
Default value for the field
EmailField
Email address input field.
type: 'email'
Discriminator for email field type
minLength?: number
Minimum character length
maxLength?: number
Maximum character length
default?: string
Default value for the field
UriField
URI/URL input field.
type: 'uri'
Discriminator for URI field type
minLength?: number
Minimum character length
maxLength?: number
Maximum character length
pattern?: string
Regular expression pattern for validation
default?: string
Default value for the field
UuidField
UUID input field.
type: 'uuid'
Discriminator for UUID field type
minLength?: number
Minimum character length
maxLength?: number
Maximum character length
pattern?: string
Regular expression pattern for validation
default?: string
Default value for the field
MoneyField
Monetary amount input field.
type: 'money'
Discriminator for money field type
min?: number
Minimum allowed amount
max?: number
Maximum allowed amount
default?: Money
Default value for the field
PercentageField
Percentage input field (0-100 by default).
type: 'percentage'
Discriminator for percentage field type
min?: number
Minimum allowed percentage
max?: number
Maximum allowed percentage
precision?: number
Number of decimal places
default?: number
Default value for the field
RatingField
Rating input field (1-5 by default).
type: 'rating'
Discriminator for rating field type
min?: number
Minimum rating value
max?: number
Maximum rating value
step?: number
Rating increment step
default?: number
Default value for the field
AddressField
Postal address input field.
type: 'address'
Discriminator for address field type
default?: Address
Default value for the field
PhoneField
Phone number input field.
type: 'phone'
Discriminator for phone field type
default?: Phone
Default value for the field
CoordinateField
Geographic coordinate (latitude/longitude) input field.
type: 'coordinate'
Discriminator for coordinate field type
default?: Coordinate
Default value for the field
BboxField
Geographic bounding box input field.
type: 'bbox'
Discriminator for bbox field type
default?: Bbox
Default value for the field
DurationField
Duration input field (ISO 8601 format).
type: 'duration'
Discriminator for duration field type
default?: Duration
Default value for the field
PersonField
Person information input field.
type: 'person'
Discriminator for person field type
default?: Person
Default value for the field
OrganizationField
Organization information input field.
type: 'organization'
Discriminator for organization field type
default?: Organization
Default value for the field
IdentificationField
Identification document input field.
type: 'identification'
Discriminator for identification field type
allowedTypes?: string[]
Allowed identification document types
default?: Identification
Default value for the field
FieldsetField
Nested fieldset containing other fields.
type: 'fieldset'
Discriminator for fieldset field type
fields: Record<string, FormField>
Nested field definitions keyed by identifier
Examples
fields:
# Text field with validation
firstName:
type: text
label: First Name
required: true
minLength: 1
maxLength: 100
# Email field
email:
type: email
label: Email Address
required: true
# Enum dropdown
preferredContact:
type: enum
label: Preferred Contact Method
enum: ["email", "phone", "mail"]
default: email
# Money field
annualIncome:
type: money
label: Annual Income
required: true
min: 0
# Date with constraints
birthDate:
type: date
label: Date of Birth
max: "2006-01-01"
# Conditional field
spouseName:
type: person
label: Spouse Information
visible: "fields.maritalStatus.value == 'married'"
required: "fields.maritalStatus.value == 'married'"
# Nested fieldset
emergencyContact:
type: fieldset
label: Emergency Contact
fields:
name:
type: text
label: Contact Name
required: true
phone:
type: phone
label: Contact Phone
required: true
Related
- Form - Form artifact overview
- Logic - Conditional expressions
- Primitives - Primitive types used as field defaults