UNPKG

972 BTypeScriptView Raw
1import { FileValidator } from './file-validator.interface';
2import { IFile } from './interfaces';
3export type FileTypeValidatorOptions = {
4 fileType: string | RegExp;
5};
6/**
7 * Defines the built-in FileType File Validator. It validates incoming files mime-type
8 * matching a string or a regular expression. Note that this validator uses a naive strategy
9 * to check the mime-type and could be fooled if the client provided a file with renamed extension.
10 * (for instance, renaming a 'malicious.bat' to 'malicious.jpeg'). To handle such security issues
11 * with more reliability, consider checking against the file's [magic-numbers](https://en.wikipedia.org/wiki/Magic_number_%28programming%29)
12 *
13 * @see [File Validators](https://docs.nestjs.com/techniques/file-upload#validators)
14 *
15 * @publicApi
16 */
17export declare class FileTypeValidator extends FileValidator<FileTypeValidatorOptions, IFile> {
18 buildErrorMessage(): string;
19 isValid(file?: IFile): boolean;
20}