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

Function validateAttachmentFileType

apps/sim/lib/uploads/utils/validation.ts:238–251  ·  view source on GitHub ↗
(fileName: string)

Source from the content-addressed store, hash-verified

236 * reasonably attach to a chat message. Rejects executables and unknown types.
237 */
238export 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

Callers 2

validation.test.tsFile · 0.90
route.tsFile · 0.90

Calls 2

extractExtensionFunction · 0.85
isAlphanumericExtensionFunction · 0.85

Tested by

no test coverage detected