UNPKG

860 BTypeScriptView Raw
1import { IFile } from './interfaces';
2/**
3 * Interface describing FileValidators, which can be added to a ParseFilePipe
4 *
5 * @see {ParseFilePipe}
6 * @publicApi
7 */
8export declare abstract class FileValidator<TValidationOptions = Record<string, any>, TFile extends IFile = IFile> {
9 protected readonly validationOptions: TValidationOptions;
10 constructor(validationOptions: TValidationOptions);
11 /**
12 * Indicates if this file should be considered valid, according to the options passed in the constructor.
13 * @param file the file from the request object
14 */
15 abstract isValid(file?: TFile | TFile[] | Record<string, TFile[]>): boolean | Promise<boolean>;
16 /**
17 * Builds an error message in case the validation fails.
18 * @param file the file from the request object
19 */
20 abstract buildErrorMessage(file: any): string;
21}