@@ -31,6 +31,7 @@ import type {
3131import {
3232 COLUMN_TYPES ,
3333 FILTER_OPS ,
34+ MAX_REFERENCE_TABLE_ID_LENGTH ,
3435 MAX_RUN_TARGET_ROW_IDS ,
3536 MAX_SELECT_OPTIONS ,
3637 MAX_TABLE_BATCH_ITEMS ,
@@ -83,15 +84,18 @@ export const currencyCodeSchema = z
8384 . regex ( / ^ [ A - Z a - z ] { 3 } $ / , 'Must be a 3-letter ISO 4217 currency code, e.g. USD' )
8485 . overwrite ( ( code ) => code . toUpperCase ( ) )
8586
86- export const referenceTableIdSchema = requiredFieldSchema ( 'Reference table ID is required' )
87+ export const referenceTableIdSchema = requiredFieldSchema ( 'Reference table ID is required' ) . max (
88+ MAX_REFERENCE_TABLE_ID_LENGTH ,
89+ `Reference table ID must be ${ MAX_REFERENCE_TABLE_ID_LENGTH } characters or less`
90+ )
8791
8892/**
8993 * Cross-field rules for type-owned metadata. A `select` column must declare a
9094 * non-empty option set, a `reference` column must declare its target table,
9195 * and type-specific fields are rejected on every type that does not own them.
9296 * Skipped when `type` is absent (a metadata-only update on an existing column).
9397 */
94- export function refineColumnOptions (
98+ export function refineColumnTypeMetadata (
9599 data : {
96100 type ?: ( typeof COLUMN_TYPES ) [ number ]
97101 options ?: z . infer < typeof selectOptionsSchema >
@@ -241,7 +245,7 @@ export const tableColumnSchema = z
241245 . optional ( )
242246 . describe ( 'Target table whose row IDs are stored by a reference column.' ) ,
243247 } )
244- . superRefine ( refineColumnOptions )
248+ . superRefine ( refineColumnTypeMetadata )
245249 . describe ( 'A typed column in a table schema.' )
246250
247251export const createTableBodySchema = z . object ( {
@@ -326,7 +330,7 @@ export const createTableColumnBodySchema = z.object({
326330 . optional ( )
327331 . describe ( 'Target table for a reference column.' ) ,
328332 } )
329- . superRefine ( refineColumnOptions )
333+ . superRefine ( refineColumnTypeMetadata )
330334 . describe ( 'Typed column definition to add.' ) ,
331335} )
332336
@@ -346,7 +350,7 @@ export const updateTableColumnBodySchema = z.object({
346350 . optional ( )
347351 . describe ( 'New target table for a reference column.' ) ,
348352 } )
349- . superRefine ( refineColumnOptions )
353+ . superRefine ( refineColumnTypeMetadata )
350354 . describe ( 'Column fields to update.' ) ,
351355} )
352356
0 commit comments