@@ -113,14 +113,43 @@ export interface FieldOption {
113113 * Extends the Protocol Field definition with runtime-specific properties.
114114 * The Protocol Constitution (SpecField) defines the core field schema.
115115 * This adds runtime conveniences and extensions.
116+ *
117+ * We make certain spec fields optional since Zod applies defaults at parse time.
116118 */
117- export interface FieldConfig extends Omit < Field , 'type' | 'options' > {
119+ export interface FieldConfig extends Omit < Field , 'type' | 'options' | 'required' | 'multiple' | 'unique' | 'deleteBehavior' | 'hidden' | 'readonly' | 'encryption' | 'index' | 'externalId' > {
118120 /** The data type of the field (extended with runtime types) */
119121 type : FieldType ;
120122
121123 /** Options for select fields (extended to allow number values) */
122124 options ?: FieldOption [ ] ;
123125
126+ /** Whether the field is mandatory. Defaults to false. */
127+ required ?: boolean ;
128+
129+ /** Whether the field allows multiple values. */
130+ multiple ?: boolean ;
131+
132+ /** Whether the field is unique in the table. */
133+ unique ?: boolean ;
134+
135+ /** Delete behavior for relationships */
136+ deleteBehavior ?: 'set_null' | 'cascade' | 'restrict' ;
137+
138+ /** Whether the field is hidden from default UI/API response. */
139+ hidden ?: boolean ;
140+
141+ /** Whether the field is read-only in UI. */
142+ readonly ?: boolean ;
143+
144+ /** Whether the field is encrypted */
145+ encryption ?: boolean ;
146+
147+ /** Whether to create a database index for this field. */
148+ index ?: boolean ;
149+
150+ /** Whether this is an external ID field */
151+ externalId ?: boolean ;
152+
124153 /**
125154 * RUNTIME EXTENSIONS BELOW
126155 * These properties are NOT in the wire protocol but are useful for the runtime.
@@ -174,10 +203,35 @@ export interface FieldConfig extends Omit<Field, 'type' | 'options'> {
174203
175204 /**
176205 * Regular expression pattern for validation.
177- * @deprecated Use SpecField validation pattern instead
206+ * @deprecated Use validation. pattern instead
178207 */
179208 regex ?: string ;
180209
210+ /**
211+ * Field validation configuration.
212+ * Defines validation rules applied at the field level.
213+ */
214+ validation ?: {
215+ /** Format validation (email, url, etc.) */
216+ format ?: 'email' | 'url' | 'phone' | 'date' | 'datetime' ;
217+ /** Allowed protocols for URL validation */
218+ protocols ?: string [ ] ;
219+ /** Minimum value for numbers */
220+ min ?: number ;
221+ /** Maximum value for numbers */
222+ max ?: number ;
223+ /** Minimum length for strings */
224+ min_length ?: number ;
225+ /** Maximum length for strings */
226+ max_length ?: number ;
227+ /** Regular expression pattern for validation */
228+ pattern ?: string ;
229+ /** Regex pattern (alias for pattern) */
230+ regex ?: string ;
231+ /** Custom validation message */
232+ message ?: string ;
233+ } ;
234+
181235 /**
182236 * AI context for the field.
183237 * Provides semantic information for AI tools.
0 commit comments