Files & Upload Validation
Built-in schemas for single and multi-part upload validation, MIME checks, size limits, and storage policies.
Single File: infer.file()
Validate file objects with size bounds, permitted MIME types, file extensions, and storage drivers:
Schema Definition
const AvatarUpload = infer.file()
.mime(["image/png", "image/jpeg", "image/webp"])
.extension(["png", "jpg", "jpeg", "webp"])
.min(1024) // 1 KB minimum
.max(5 * 1024 * 1024) // 5 MB maximum
.storage("memory"); // "memory" | "disk"Multiple Files: infer.files()
Validate arrays of uploaded files with collective count limits and per-file thresholds:
Schema Definition
const AttachmentBatch = infer.files()
.min(1)
.max(5)
.mime(["application/pdf", "image/*"])
.maxEach(10 * 1024 * 1024); // 10MB each