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(exact): validate oneOf chains #1282

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

fedeci
Copy link
Member

@fedeci fedeci commented Feb 22, 2024

Description

Closes #1269

To-do list

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

@coveralls
Copy link

coveralls commented Feb 22, 2024

Coverage Status

coverage: 100.0%. remained the same
when pulling d371fc3 on fedeci:fedeci/feat/exact-and-oneof
into ffd7994 on express-validator:master.

Copy link
Member Author

@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.

This is a possible solution to close the linked issue. I would like to work a little bit more on this one to make the code cleaner.

Comment on lines +45 to +49
pushSubcontext(...contexts: ReadonlyContext[]) {
this.subcontexts.push(...contexts);
return this;
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Before merging this I want experiment with inheritance of contexts to see if I can create separate contexts for each of the middlewares we provide. All of them would conform to a shared interface, so that some methods are easily callable without type casting.

return;
(internalReq[contextsKey] || [])
.flatMap(context => {
// TODO: This does not work for nested oneOf
Copy link
Member Author

Choose a reason for hiding this comment

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

This is something I feel that inherited contexts may help to achieve

Comment on lines -13 to -18
import { ContextItem } from '../context-items';
import { runAllChains } from '../utils';

// A dummy context item that gets added to surrogate contexts just to make them run
const dummyItem: ContextItem = { async run() {} };

Copy link
Member Author

Choose a reason for hiding this comment

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

Was this useful? Removing it did not make any test to fail.

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.

Using oneOf together with checkExact causes Unknown Field errors
2 participants