FileValidator

Interface describing FileValidators, which can be added to a ParseFilePipe

  
abstract class FileValidator<TValidationOptions = Record<string, any>, TFile extends IFile = IFile> {
  constructor(validationOptions: TValidationOptions)
  protected validationOptions: TValidationOptions
  abstract isValid(file?: TFile | TFile[] | Record<string, TFile[]>): boolean | Promise<boolean>
  abstract buildErrorMessage(file: any): string
}

See also

  • {ParseFilePipe}

Constructor


constructor(validationOptions: TValidationOptions)

Parameters

Option Type Description
validationOptions TValidationOptions

Properties

Property Description
protected validationOptions: TValidationOptions Read-only. Declared in constructor.

Methods

isValid()

Indicates if this file should be considered valid, according to the options passed in the constructor.


abstract isValid(file?: TFile | TFile[] | Record<string, TFile[]>): boolean | Promise<boolean>

Parameters

Option Type Description
file TFile | TFile[] | Record

the file from the request object


Optional. Default is `undefined`.

Returns

boolean | Promise<boolean>

buildErrorMessage()

Builds an error message in case the validation fails.


abstract buildErrorMessage(file: any): string

Parameters

Option Type Description
file any

the file from the request object

Returns

string