mirror of
https://github.com/nestjs/nest.git
synced 2026-02-21 23:11:44 +00:00
chore(common): temporarily move file-type to regular deps
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"file-type": "20.4.1",
|
||||
"iterare": "1.2.1",
|
||||
"tslib": "2.8.1",
|
||||
"uid": "2.0.2"
|
||||
@@ -25,7 +26,6 @@
|
||||
"peerDependencies": {
|
||||
"class-transformer": "*",
|
||||
"class-validator": "*",
|
||||
"file-type": "^20.4.1",
|
||||
"reflect-metadata": "^0.1.12 || ^0.2.0",
|
||||
"rxjs": "^7.1.0"
|
||||
},
|
||||
@@ -35,9 +35,6 @@
|
||||
},
|
||||
"class-transformer": {
|
||||
"optional": true
|
||||
},
|
||||
"file-type": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,19 @@ export class FileTypeValidator extends FileValidator<
|
||||
FileTypeValidatorOptions,
|
||||
IFile
|
||||
> {
|
||||
constructor(validationOptions: FileTypeValidatorOptions) {
|
||||
super(validationOptions);
|
||||
|
||||
// check if file-type is installed
|
||||
try {
|
||||
require.resolve('file-type');
|
||||
} catch (e) {
|
||||
throw new Error(
|
||||
`FileTypeValidator requires the file-type package. Please install it: npm i file-type`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
buildErrorMessage(file?: IFile): string {
|
||||
if (file?.mimetype) {
|
||||
return `Validation failed (current file type is ${file.mimetype}, expected type is ${this.validationOptions.fileType})`;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import {
|
||||
BadRequestException,
|
||||
PipeTransform,
|
||||
Injectable,
|
||||
ArgumentMetadata,
|
||||
BadRequestException,
|
||||
Injectable,
|
||||
PipeTransform,
|
||||
} from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
|
||||
Reference in New Issue
Block a user