MCPcopy Index your code
hub / github.com/simstudioai/sim / validateColumnDefinition

Function validateColumnDefinition

apps/sim/lib/table/validation.ts:664–691  ·  view source on GitHub ↗
(column: ColumnDefinition)

Source from the content-addressed store, hash-verified

662
663/** Validates column definition format and type. */
664export function validateColumnDefinition(column: ColumnDefinition): ValidationResult {
665 const errors: string[] = []
666
667 if (!column.name || typeof column.name !== 'string') {
668 errors.push('Column name is required')
669 return { valid: false, errors }
670 }
671
672 if (column.name.length > TABLE_LIMITS.MAX_COLUMN_NAME_LENGTH) {
673 errors.push(
674 `Column name "${column.name}" exceeds maximum length (${TABLE_LIMITS.MAX_COLUMN_NAME_LENGTH} characters)`
675 )
676 }
677
678 if (!NAME_PATTERN.test(column.name)) {
679 errors.push(
680 `Column name "${column.name}" must start with letter or underscore, followed by alphanumeric or underscore`
681 )
682 }
683
684 if (!COLUMN_TYPES.includes(column.type)) {
685 errors.push(
686 `Column "${column.name}" has invalid type "${column.type}". Valid types: ${COLUMN_TYPES.join(', ')}`
687 )
688 }
689
690 return { valid: errors.length === 0, errors }
691}

Callers 2

validation.test.tsFile · 0.90
validateTableSchemaFunction · 0.85

Calls 3

testMethod · 0.80
joinMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected