UNPKG

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