(name: string)
| 152 | |
| 153 | /** Validates table name format and length. */ |
| 154 | export function validateTableName(name: string): ValidationResult { |
| 155 | const errors: string[] = [] |
| 156 | |
| 157 | if (!name || typeof name !== 'string') { |
| 158 | errors.push('Table name is required') |
| 159 | return { valid: false, errors } |
| 160 | } |
| 161 | |
| 162 | if (name.length > TABLE_LIMITS.MAX_TABLE_NAME_LENGTH) { |
| 163 | errors.push( |
| 164 | `Table name exceeds maximum length (${TABLE_LIMITS.MAX_TABLE_NAME_LENGTH} characters)` |
| 165 | ) |
| 166 | } |
| 167 | |
| 168 | if (!NAME_PATTERN.test(name)) { |
| 169 | errors.push( |
| 170 | 'Table name must start with letter or underscore, followed by alphanumeric or underscore' |
| 171 | ) |
| 172 | } |
| 173 | |
| 174 | return { valid: errors.length === 0, errors } |
| 175 | } |
| 176 | |
| 177 | /** Validates table schema structure and column definitions. */ |
| 178 | export function validateTableSchema(schema: TableSchema): ValidationResult { |
no test coverage detected