@@ -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 ,
@@ -85,15 +86,18 @@ export const currencyCodeSchema = z
8586 . regex ( / ^ [ A - Z a - z ] { 3 } $ / , 'Must be a 3-letter ISO 4217 currency code, e.g. USD' )
8687 . overwrite ( ( code ) => code . toUpperCase ( ) )
8788
88- export const referenceTableIdSchema = requiredFieldSchema ( 'Reference table ID is required' )
89+ export const referenceTableIdSchema = requiredFieldSchema ( 'Reference table ID is required' ) . max (
90+ MAX_REFERENCE_TABLE_ID_LENGTH ,
91+ `Reference table ID must be ${ MAX_REFERENCE_TABLE_ID_LENGTH } characters or less`
92+ )
8993
9094/**
9195 * Cross-field rules for type-owned metadata. A `select` column must declare a
9296 * non-empty option set, a `reference` column must declare its target table,
9397 * and type-specific fields are rejected on every type that does not own them.
9498 * Skipped when `type` is absent (a metadata-only update on an existing column).
9599 */
96- export function refineColumnOptions (
100+ export function refineColumnTypeMetadata (
97101 data : {
98102 type ?: ( typeof COLUMN_TYPES ) [ number ]
99103 options ?: z . infer < typeof selectOptionsSchema >
@@ -243,7 +247,7 @@ export const tableColumnSchema = z
243247 . optional ( )
244248 . describe ( 'Target table whose row IDs are stored by a reference column.' ) ,
245249 } )
246- . superRefine ( refineColumnOptions )
250+ . superRefine ( refineColumnTypeMetadata )
247251 . describe ( 'A typed column in a table schema.' )
248252
249253export const createTableBodySchema = z . object ( {
@@ -328,7 +332,7 @@ export const createTableColumnBodySchema = z.object({
328332 . optional ( )
329333 . describe ( 'Target table for a reference column.' ) ,
330334 } )
331- . superRefine ( refineColumnOptions )
335+ . superRefine ( refineColumnTypeMetadata )
332336 . describe ( 'Typed column definition to add.' ) ,
333337} )
334338
@@ -348,7 +352,7 @@ export const updateTableColumnBodySchema = z.object({
348352 . optional ( )
349353 . describe ( 'New target table for a reference column.' ) ,
350354 } )
351- . superRefine ( refineColumnOptions )
355+ . superRefine ( refineColumnTypeMetadata )
352356 . describe ( 'Column fields to update.' ) ,
353357} )
354358
0 commit comments