feat(upload): validate MIME type and size on file replace in DocumentEditLayout

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-04-18 16:15:22 +02:00
committed by marcel
parent b0ea5f5552
commit d31ea12086
6 changed files with 59 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
export const ALLOWED_TYPES = new Set(['application/pdf', 'image/jpeg', 'image/png', 'image/tiff']);
export const MAX_SIZE_BYTES = 50 * 1024 * 1024;
export type FileValidationError = 'type' | 'size';
export function validateFile(file: File): FileValidationError | null {
if (!ALLOWED_TYPES.has(file.type)) return 'type';
if (file.size > MAX_SIZE_BYTES) return 'size';
return null;
}