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: add date to ignored metatypes #12656

Merged
merged 1 commit into from
Oct 25, 2023

Conversation

jmcdo29
Copy link
Member

@jmcdo29 jmcdo29 commented Oct 25, 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?

If a parameter decorator with the metatype Date is used, with the ValidationPipe with at least one validation option, then the parameter will be transformed into a date object, even if transform: false is set.

Issue Number: #12647

What is the new behavior?

Date specific parameters are now ignored, just as Array, Object, String, and Number are, for consistency

Does this PR introduce a breaking change?

  • Yes
  • No

Technically yes, but it's fixing what is a bug.

Other information

@kamilmysliwiec
Copy link
Member

LGTM

@jmcdo29 jmcdo29 deleted the fix/dates-validation branch October 25, 2023 07:56
@PodStuart
Copy link

I am not sure if this should have gone out in a patch release. We have broken e2e tests because parameters are now a string rather than a date at runtime.

@jmcdo29
Copy link
Member Author

jmcdo29 commented Nov 3, 2023

@PodStuart as I wrote in the pr description technically this has the possibility to be called a breaking change. However, it's fixing a bug, meaning that applications broken by this pr were making use of a bug rather than an intended feature

@Mualig
Copy link

Mualig commented Nov 24, 2023

How can we transform dates now ? This pipe config does not work anymore:
@UsePipes(new ValidationPipe({ skipMissingProperties: false, transform: true, whitelist: true }))
with
@Query('from') _from: Date

@jmcdo29
Copy link
Member Author

jmcdo29 commented Nov 28, 2023

@Mualig you can create a pipe that does it, or a DTO that properly has a from: Date property. The ValidaitonPipe should not have been used for built in classes as a way to do transformations. That's why we ignore Buffer, Date, and other built in classes

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.

4 participants