Return value of type `ValidationResult` contains both value and error, which is inconsistent
- 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): yes
* *is this issue affecting a production system?* (yes/no): yes
#### Context
* *node version*: v18.7.0
* *ts-node version*: v10.9.1
* *module version with issue*: joi
* *last module version without issue*: unsure
* *environment* (e.g. node, browser, native): node (ts-node)
* *used with* (e.g. hapi application, another framework, standalone, ...): standalone / hapi application
* *any other relevant information*:
Types defined as following:

or
```ts
type ValidationResult = {
error: undefined;
warning?: ValidationError;
value: TSchema;
} | {
error: ValidationError;
warning?: ValidationError;
value: undefined;
}
```
#### What are you trying to achieve or the steps to reproduce?
```ts
import Joi from 'joi';
const schema = Joi.string()
.required()
.valid('only allowed value');
const result = schema.validate("a non-allowed value");
console.log(result);
```
#### What was the result you got?
```
{
value: 'a non-allowed value',
error: [Error [ValidationError]: "value" must be [only allowed value]] {
_original: 'a non-allowed value',
details: [ [Object] ]
}
}
```
#### What result did you expect?
```
{
value: undefined,
error: [Error [ValidationError]: "value" must be [only allowed value]] {
_original: 'a non-allowed value',
details: [ [Object] ]
}
}
```
Contributor guide
Assessment
This issue has not been assessed yet.