Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(common): fix custom multi file validator #12096

Merged
merged 3 commits into from
Aug 18, 2023

Conversation

mohamadrezamomeni
Copy link
Contributor

@mohamadrezamomeni mohamadrezamomeni commented Jul 22, 2023

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@mohamadrezamomeni
Copy link
Contributor Author

hello I want to write custom validator for multi files, I get exception type checking in multi files everything is ok for uploading single file

@coveralls
Copy link

coveralls commented Jul 22, 2023

Pull Request Test Coverage Report for Build d27548e2-674d-4694-90b7-bd77ea4d9ad3

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 92.813%

Totals Coverage Status
Change from base Build a6dafcb9-fea7-49b0-9944-8692bb0562ae: 0.0%
Covered Lines: 6392
Relevant Lines: 6887

💛 - Coveralls

@@ -16,7 +16,7 @@ export abstract class FileValidator<
* Indicates if this file should be considered valid, according to the options passed in the constructor.
* @param file the file from the request object
*/
abstract isValid(file?: TFile): boolean | Promise<boolean>;
abstract isValid(file?: TFile | TFile[] | Record<string, TFile[]>): boolean | Promise<boolean>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we move this to the L11 instead as

TFile extends IFile | TFile[] | Record<string, TFile[]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@micalevisk I think your idea is good thank you for your answer

Copy link
Member

@micalevisk micalevisk Jul 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, that won't work the same because we need to use IFile[], not TFile[], as in the current version. I just tested. Also, extends FileValidator<MyFile> looks better than extends FileValidator<MyFile[]>

could you please revert the commit a7c59

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think first commit is ok?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Contributor Author

@mohamadrezamomeni mohamadrezamomeni Jul 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@micalevisk i reverted to the a7c59 , is it ok right now?

This reverts commit a7c5963.
@kamilmysliwiec kamilmysliwiec merged commit f3d6f99 into nestjs:master Aug 18, 2023
4 of 5 checks passed
@kamilmysliwiec
Copy link
Member

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants