ValidationResult type inconsistent with API
- 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*: 14.13.1
* *module version with issue*: 17.3.0
* *last module version without issue*: n/a
* *environment* (e.g. node, browser, native): node
* *used with* (e.g. hapi application, another framework, standalone, ...): standalone
* *any other relevant information*:
#### What are you trying to achieve or the steps to reproduce?
I'm using the built-in types and found an inconsistency in the `ValidationResult` type. According to the [API reference](https://joi.dev/api/?v=17.3.0#anyvalidatevalue-options), `validate()` should return the following elements as `ValidationResult`.
> Returns an object with the following keys:
>
> `value` - the validated and normalized value.
> - `error` - the validation errors if found.
> - `warning` - the generated warnings if any.
> - `artifacts` - a `Map` containing any passing rules' artifacts and their corresponding array of paths.
The type specifies the following, in v17.3.0, where `errors` is added, and `artifacts` is not present.
```ts
interface ValidationResult {
error?: ValidationError;
errors?: ValidationError;
warning?: ValidationError;
value: any;
}
```
#### What was the result you got?
Inconsistent `ValidationResult` type.
#### What result did you expect?
Type `ValidationResult` consistent with API.
Contributor guide
Assessment
This issue has not been assessed yet.