Skip to content

Commit

Permalink
fix(common): drop class-validator imports
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Feb 1, 2023
1 parent 0a4f941 commit 91f7190
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions packages/common/pipes/file/parse-file.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { Injectable, Optional } from '../../decorators/core';
import { HttpStatus } from '../../enums';
import { PipeTransform } from '../../interfaces/features/pipe-transform.interface';
import { HttpErrorByCode } from '../../utils/http-error-by-code.util';
import { isEmpty, isObject, isUndefined } from '../../utils/shared.utils';
import { FileValidator } from './file-validator.interface';
import { ParseFileOptions } from './parse-file-options.interface';
import { isEmpty, isObject } from 'class-validator';

/**
* Defines the built-in ParseFile Pipe. This pipe can be used to validate incoming files
Expand Down Expand Up @@ -62,11 +62,9 @@ export class ParseFilePipe implements PipeTransform<any> {
}

private thereAreNoFilesIn(value: any): boolean {
if (Array.isArray(value)) {
return value.length === 0;
} else {
return isEmpty(value);
}
const isEmptyArray = Array.isArray(value) && isEmpty(value);
const isEmptyObject = isObject(value) && isEmpty(Object.keys(value));
return isUndefined(value) || isEmptyArray || isEmptyObject;
}

protected async validate(file: any): Promise<any> {
Expand Down

0 comments on commit 91f7190

Please sign in to comment.