We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 77c4327 commit 370267bCopy full SHA for 370267b
src/utils.ts
@@ -15,18 +15,20 @@ export function asyncResultsAnd(asyncResults: Array<Promise<ValidationResult>>):
15
return null
16
}
17
return new Promise(resolve => {
18
- // 任一不通过,则不通过
+ let validResultCount = 0
19
asyncResults.forEach(asyncResult => asyncResult.then(result => {
20
+ // return error if any result is invalid
21
if (!isValid(result)) {
22
resolve(result)
23
+ return
24
- }))
- // 所有都通过,则通过
25
- return Promise.all(asyncResults).then(results => {
26
- if (results.every(isValid)) {
+
+ validResultCount++
27
+ // pass if all results are valid
28
+ if (validResultCount === asyncResults.length) {
29
resolve(null)
30
- })
31
+ }))
32
})
33
34
0 commit comments