Warning on rejected async validation
- Dominant language
- JavaScript
- Stars
- 21.2k
- Forks
- 1.5k
- Avg merge
- 4h 57m
- Merged PRs (30d)
- 14
Description
### Runtime
node.js
### Runtime version
18+
### Module version
17.13.3
### Last module version without issue
_No response_
### Used with
standalone
### Any other relevant information
_No response_
### What are you trying to achieve or the steps to reproduce?
Currently synchronous validation returns `ValidationResult` type, which is following:
```typescript
type ValidationResult = {
error: undefined;
warning?: ValidationError;
value: TSchema;
} | {
error: ValidationError;
warning?: ValidationError;
value: any;
}
```
So both in case of successful validation and error we always have warnings in the result. But when switching to asynchronous validation with warnings turned on `validateAsync(value, { warnings: true })` in case of error the promise rejects and we have only `ValidationError` which doesn't incllude any warnings.
If this is by design, and synchronous and asynchronous validation have that difference, then it's not documented anywhere clearly.
**Is there any way to still have the warnings in case of promise rejection for async validation?**
### What was the result you got?
`error` on promise rejection
### What result did you expect?
`error` with warnings included
Contributor guide
Assessment
This issue has not been assessed yet.