( file: File, maxSizeBytes: number, label = 'File' )
| 65 | maxSizeBytes: number, |
| 66 | label = 'File' |
| 67 | ): string | null { |
| 68 | if (file.size > maxSizeBytes) { |
| 69 | return `${label} too large: ${formatFileSize(file.size)}. Maximum: ${formatFileSize(maxSizeBytes)}`; |
| 70 | } |
| 71 | return null; |
| 72 | } |
| 73 | |
| 74 | function validateImageFileType(file: File, allowedTypes: readonly string[]): string | null { |
| 75 | if (!isAllowedImageType(file.type, allowedTypes)) { |
| 76 | return `Invalid file type: ${file.type}. Allowed: ${allowedTypes.join(', ')}`; |
| 77 | } |
| 78 | return null; |
| 79 | } |
no test coverage detected