Closed romulof closed 1 year ago
abortEarly
causes yup to return after the first error it finds, that doesn't mean tests are run sequentially. All tests are run in parallel, using Promise.all
depth first through the schema, with abortEarly set it will stop as soon as an error is thrown, but doesn't provide any guarantees which error throws first
If all tests are run with Promise.all
how do you abort existing ones when you find an error?
Promise.all
will execute all and resolve once they are done. The only difference I see is on error reporting, that instead of reporting a list of errors, it would report just the first.
The naming of this property is misleading, because it is not "early".
Promise.all will execute all and resolve once they are done.
That's not quite right. Promise.all
resolves as soon as a one of it's promises rejects. I understand your confusion and yes
returnEarly
or rejectEarly
is probably a better name, but it is in fact returning "early".
The only difference I see is on error reporting.
Mostly correct. but it's not just reporting the first one, it's returning control to you as soon as an error returns instead of waiting for every test to finish.
Describe the bug
When calling
.validate(value, { abortEarly: true });
for a schema with async test, it won't abort early.To Reproduce
https://codesandbox.io/s/holy-voice-dcwlw2
Expected behavior
asyncTest
should not be called if a previous check (.required()
and.email()
in the example) fail.Platform (please complete the following information):
Additional context
N/A