11 lines
387 B
TypeScript
11 lines
387 B
TypeScript
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;
|
|
}
|