Skip to content

Commit

Permalink
Fix async validation in case when promise is resolved with some data (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
afitiskin authored and erikras committed May 31, 2018
1 parent 58bdb48 commit a57465a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/asyncValidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ const asyncValidation = (
)
}
const handleErrors = rejected => errors => {
if (errors && Object.keys(errors).length) {
stop(errors)
return errors
} else if (rejected) {
stop()
throw new Error(
'Asynchronous validation promise was rejected without errors.'
)
if (rejected) {
if (errors && Object.keys(errors).length) {
stop(errors)
return errors
} else {
stop()
throw new Error(
'Asynchronous validation promise was rejected without errors.'
)
}
}
stop()
return Promise.resolve()
Expand Down

0 comments on commit a57465a

Please sign in to comment.