fix(common)!: when transforming optional boolean parameters on ValidationPipe
#10953
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: the issue #10246 is broader than what this PR address. For optional boolean values, when they are not supplied, the value is parsed to
false
What is the new behavior?
(using
ValidationPipe({ transform: true })
)This only fixes(?) the following use case:
now leads to
foo === undefined
if no query/path parameter forfoo
key was supplied instead of always failing back tofalse
. Note that marking them as optional doesn't matterDoes this PR introduce a breaking change?
undefined
instead offalse
(unless this was a design decision forValidationPipe
when dealing with primitive values). If this introduces a breaking change, you can close it. If they want to model false as the default value, they should use this: