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

feat(matchedData): add discardUndefined option when selecting fields #1275

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

Vladyslav531
Copy link

@Vladyslav531 Vladyslav531 commented Jan 30, 2024

Description

Add ignoreUndefined to includeOptionals in matchedData

ignoreUndefined allows user to pass optional values which aren't undefined like null and falsy values.
It keeps current behaviour and allow user to customize matchedData.

Closes #1048
Closes #1175
Closes #1273

To-do list

  • I have added tests for what I changed.
  • This pull request is ready to merge.

@Vladyslav531
Copy link
Author

@gustavohenke Could you check this PR please?

@coveralls
Copy link

coveralls commented Feb 13, 2024

Coverage Status

coverage: 100.0%. remained the same
when pulling 5e783d3 on Vladyslav531:feat/ignoreUndefined
into ffd7994 on express-validator:master.

Copy link
Member

@fedeci fedeci left a comment

Choose a reason for hiding this comment

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

Thanks! Looks like a good new feature, there are some changes to publish this in a minor version.

src/matched-data.ts Outdated Show resolved Hide resolved
src/context.ts Outdated Show resolved Hide resolved
src/context.spec.ts Show resolved Hide resolved
src/matched-data.ts Outdated Show resolved Hide resolved
src/context.ts Outdated Show resolved Hide resolved
Copy link
Member

@fedeci fedeci left a comment

Choose a reason for hiding this comment

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

Thanks! Looks like a good new feature, there are some changes to publish this in a minor version.

@fedeci fedeci changed the title feat: ignoreUndefined in includeOptional feat(matchedData): add ignoreUndefined option when selecting fields Feb 16, 2024
@fedeci
Copy link
Member

fedeci commented Feb 16, 2024

Also, docs should be updated too once we are good to go with the implementation and the new API.

@Vladyslav531
Copy link
Author

Also, docs should be updated too once we are good to go with the implementation and the new API.

I update docs, you can check

@Vladyslav531
Copy link
Author

@fedeci I updated code to keep signature of context. You can check again

src/matched-data.ts Outdated Show resolved Hide resolved
src/context.spec.ts Outdated Show resolved Hide resolved
src/context.ts Outdated Show resolved Hide resolved
@fedeci
Copy link
Member

fedeci commented Feb 20, 2024

I also changed my mind on the naming of ignoreUndefined. It may be confusing. What about discardUndefined?
/cc @gustavohenke

@Vladyslav531
Copy link
Author

I also changed my mind on the naming of ignoreUndefined. It may be confusing. What about discardUndefined? /cc @gustavohenke

I think it is also good name.

@Vladyslav531 Vladyslav531 changed the title feat(matchedData): add ignoreUndefined option when selecting fields feat(matchedData): add discardUndefined option when selecting fields Feb 20, 2024
src/matched-data.spec.ts Outdated Show resolved Hide resolved
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.

How to keep keys for optional fields in matchedData? matchedData does not include nullable optionals
3 participants