Utilities
Low-level helpers used by the hooks. Safe to call from your own file pickers if you are not using useDropzone.
ts
import { isFileAccepted, acceptPatternsToInputAccept, validateFiles } from 'react-upload-kit';isFileAccepted
ts
function isFileAccepted(
file: Pick<File, 'name' | 'type'>,
accept: AcceptPattern[] | undefined,
): booleanReturns true if accept is empty/undefined, or if any pattern matches.
.pdf— filename suffix, case-insensitiveimage/*— MIME groupimage/png— exact MIME
acceptPatternsToInputAccept
ts
function acceptPatternsToInputAccept(
accept: AcceptPattern[] | undefined,
): string | undefinedJoins patterns with commas for <input accept="…">. Returns undefined when there is nothing to set.
validateFiles
ts
function validateFiles(
files: File[],
config: {
accept?: AcceptPattern[];
maxFileSize?: number;
minFileSize?: number;
maxFiles?: number;
validator?: FileValidator;
},
existingFileCount?: number,
): { accepted: File[]; rejected: FileRejection[] }existingFileCount (default 0) is how many files are already tracked. useUploader passes files.length so maxFiles is global. A standalone picker should pass the same number if it shares that cap.
A file is rejected if it has any error. Custom validator errors are appended after built-in checks; a file can have several errors at once.