(fileName: string)
| 236 | * reasonably attach to a chat message. Rejects executables and unknown types. |
| 237 | */ |
| 238 | export function validateAttachmentFileType(fileName: string): FileValidationError | null { |
| 239 | const raw = extractExtension(fileName) |
| 240 | const extension = isAlphanumericExtension(raw) ? raw : '' |
| 241 | |
| 242 | if (!SUPPORTED_ATTACHMENT_EXTENSIONS.includes(extension)) { |
| 243 | return { |
| 244 | code: 'UNSUPPORTED_FILE_TYPE', |
| 245 | message: `Unsupported file type${extension ? `: ${extension}` : ` for "${fileName}"`}. Supported types include documents, code, images, audio, and video.`, |
| 246 | supportedTypes: [...SUPPORTED_ATTACHMENT_EXTENSIONS], |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | return null |
| 251 | } |
| 252 | |
| 253 | /** |
| 254 | * Validate if a file type is supported for document processing |
no test coverage detected