-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
feat: Add optional support to pipes #11879
feat: Add optional support to pipes #11879
Conversation
isOptional
property to ParseEnumPipe
for optional parameter support
isOptional
property to ParseEnumPipe
for optional parameter supportisOptional
property to ParseEnumPipe
for optional parameter support
…dlrahmanSaberAbdo:AbdlrahmanSaberAbdo/nest into optional-validation-for-parseEnumPipe
af19852
to
10d5a86
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kamilmysliwiec Thank you for your comments. I have implemented the requested changes. Should I open a new PR specifically for the other pipes? or should we first decide which pipes should be optional?
Pull Request Test Coverage Report for Build 002d47fb-fb1d-47c3-a863-1ceb404778b9
💛 - Coveralls |
0fd6722
to
9359160
Compare
for consistency sake I think we should update all the other pipes here as well
|
Do you think that should I change the PR title to reflect the changes I made for adding the |
isOptional
property to ParseEnumPipe
for optional parameter support
I updated other pipes, if you think that we should do it in another PR let me know. parse-array already has an optional property. |
@kamilmysliwiec @micalevisk I checked the failed test but did not really get why it fails, I don't think that's related to my changes, any inputs would be appreciated! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks good so far, But i think a documentation update about this on the pipes section should follow as well
LGTM |
This PR introduced a bug where these validators throw an (unexpected) error if the value is missing and the options argument wasn't supplied: if (isNil(value) && this.options.optional) { // Cannot read properties of undefined (reading 'optional')
return value;
} |
Thanks for pointing this out |
Fixed in 10.0.5 |
Could someone tells me what I'm doing wrong in this case? I'm trying to use the property
The defintion:
|
Fixed, changed to: @Query('apigeeVersion', new ParseEnumPipe(ApigeeVersionEnum, { optional: true }))
apigeeVersion: ApigeeVersionEnum And added before the method: @ApiQuery({ name: 'apigeeVersion', type: ApigeeVersionDto }) |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: #11865
What is the new behavior?
Does this PR introduce a breaking change?
Other information