Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(common): add message property to file type validator#16060

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Jo-Minseok wants to merge8 commits intonestjs:master
base:master
Choose a base branch
Loading
fromJo-Minseok:feat/filevalidator-custom-message

Conversation

@Jo-Minseok
Copy link

@Jo-MinseokJo-Minseok commentedDec 12, 2025
edited
Loading

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?

Previously, only MaxFileSizeValidator supported custom messages, while FileTypeValidator did not, which caused confusion and made it difficult to deliver service-appropriate messages.
Errors were also returned as simple strings, requiring unnecessary branching through the exceptionFactory.
Now, the usage of MaxFileSizeValidator and FileTypeValidator—specifically the way custom messages are delivered—has been standardized.

Issue Number:#16058

What is the new behavior?

By enabling the use of custom messages in FileTypeValidator—as was already possible in MaxFileSizeValidator—it is now possible to deliver service-appropriate messages and maintain consistency in how MaxFileSizeValidator and FileTypeValidator are used.
Without using exceptionFactory, simple strings can now be used in FileTypeValidator to provide messages for Bad Request responses.

In addition, the existingmessage option has been deprecated in favor of a new
errorMessage option for clearer semantics and consistency across validators.

The deprecatedmessage option is still supported for backward compatibility,
buterrorMessage is now the preferred way to provide custom error messages.

newMaxFileSizeValidator({maxSize:1000,message:'Error'});// 🟢 Although deprecated, this option is still supported.newMaxFileSizeValidator({maxSize:1000,errorMessage:'Error'});// 🟢 New PropertynewMaxFileSizeValidator({maxSize:1000,errorMessage:ctx=>`Received file size is${ctx.file?.size}, but it must be smaller than${ctx.config.maxSize}.`});// 🟢 New Property with factory function
newFileTypeValidator({fileType:'image/png',message:'invalid type'});// ❌ Since this property did not previously exist, it cannot be used.newFileTypeValidator({fileType:'image/png',errorMessage:'invalid type'});// 🟢New PropertynewFileTypeValidator({fileType:'image/png',errorMessage:ctx=>`Received file type '${ctx.file?.mimetype}', but expected '${ctx.config.fileType}'.`});// 🟢 New Property with factory function

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@coveralls
Copy link

coveralls commentedDec 12, 2025
edited
Loading

Pull Request Test Coverage Report forBuild 71f3c018-4d14-4733-9975-4a2037f6195e

Details

  • 10 of10(100.0%) changed or added relevant lines in2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.04%) to89.365%

TotalsCoverage Status
Change from baseBuild d186cd4d-4808-4470-82f6-43a17b6e3fe1:0.04%
Covered Lines:7378
Relevant Lines:8256

💛 -Coveralls

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@kamilmysliwieckamilmysliwiecAwaiting requested review from kamilmysliwiec

1 more reviewer

@micaleviskmicaleviskmicalevisk approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@Jo-Minseok@coveralls@micalevisk@kamilmysliwiec

[8]ページ先頭

©2009-2025 Movatter.jp