-
-
Notifications
You must be signed in to change notification settings - Fork 616
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
Request-level bail #1214
Request-level bail #1214
Conversation
@@ -62,12 +69,25 @@ export function oneOf( | |||
const middleware = async (req: InternalRequest, _res: any, next: (err?: any) => void) => { | |||
const surrogateContext = new ContextBuilder().addItem(dummyItem).build(); | |||
|
|||
// Run each group of chains in parallel, and within each group, run each chain in parallel too. |
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.
This is a perf loss, but I don't see any other way of implementing this.
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.
Latest version is better, but still a perf loss. I've added a summary of changes to the PR description.
fe2e984
to
7eaab8e
Compare
Description
Closes #1100
Implements an option to
.bail()
so that no further contexts will run if there are any errors.Supports:
oneOf
checkSchema
checkExact
Suppose that you have a request with 1k fields, one validator on each field, each taking 10ms to complete.
Also suppose that no fields present errors, so every validator runs.
On my machine, the time it takes for running all validation chains looks like this:
To-do list