-
Notifications
You must be signed in to change notification settings - Fork 929
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
Handle sync validations #2053
Handle sync validations #2053
Conversation
src/util/createValidation.ts
Outdated
if (!options.sync) { | ||
return Promise.resolve(result).then( | ||
handleResult, | ||
handleError, | ||
); | ||
} |
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.
if (!options.sync) { | |
return Promise.resolve(result).then( | |
handleResult, | |
handleError, | |
); | |
} | |
if (options.sync) | |
throw Error(...) | |
return result.then( | |
handleResult, | |
handleError, | |
); |
I think this is all you actually need here? the sync
check now only serves to throw if there is a promise when there shouldn't be
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.
SGTM, trying to think if there are potential race conditions now...there shouldn't be, or at least if their are they also affect the explicit sync
pathway as well.
this is a little Zalgo-y but i think it's probably worth it...
@jquense I spun up this little repo as a test bed: https://github.com/DaddyWarbucks/yup-sync-validation I roughly estimated the schema to have about 100 validation tests per data from the repo. Given every property has multiple tests, I just rounded to 100 for the statements below.
The problem seems to present itself when using |
Solves: #2052