Open
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:
or
type ValidationResult<TSchema = any> = {
error: undefined;
warning?: ValidationError;
value: TSchema;
} | {
error: ValidationError;
warning?: ValidationError;
value: undefined;
}
What are you trying to achieve or the steps to reproduce?
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] ]
}
}