Custom validators recieve an unresolved promise when asynchronously validating.
- Dominant language
- JavaScript
- Stars
- 21.2k
- Forks
- 1.5k
- Avg merge
- 4h 57m
- Merged PRs (30d)
- 14
Description
#### Support plan
* *is this issue currently blocking your project?* (yes/no): no
* *is this issue affecting a production system?* (yes/no): no
#### Context
* *node version*: 15.7.0
* *module version*: 17.4.0
* *environment* (e.g. node, browser, native): node
* *used with* (e.g. hapi application, another framework, standalone, ...): custom framework
* *any other relevant information*:
#### How can we help?
```js
const joi = require('joi');
joi
.string()
.custom((v) => v.slice(1))
.custom(
async (v) =>
await new Promise((res) => setTimeout(res, 10000, v.toUpperCase()))
)
.custom(
async (v) => await new Promise((res) => setTimeout(res, 10000, v, 'b'))
)
.validateAsync('foobar')
.then(console.log)
.catch(console.error);
```
The thrid custom validator recieves an unresolved promise (current workaround `v=await v; ...`)
Contributor guide
Assessment
This issue has not been assessed yet.