-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
breaking changesChange that can breaking existing codeChange that can breaking existing codebugBug or defectBug or defect
Milestone
Description
I looked through the issues (both open and closed) and could not find one describing this behavior. Here is the script to reproduce:
var Joi = require('joi');
var a = Joi.object().keys({
foo: Joi.string()
});
var b = Joi.object().keys({
foo: Joi.number()
});
var ab = a.concat(b);
console.log(Joi.validate({ foo: 'bar' }, ab));
console.log(Joi.validate({ foo: 1 }, ab));I get:
{ error:
{ [ValidationError: foo must be a number]
name: 'ValidationError',
details: [ [Object] ],
_object: { foo: 'bar' },
annotate: [Function] },
value: { foo: 'bar' } }
{ error:
{ [ValidationError: foo must be a string]
name: 'ValidationError',
details: [ [Object] ],
_object: { foo: 1 },
annotate: [Function] },
value: { foo: 1 } }
I know this use case seems a bit stupid, but it might be good to be more defensive.
This issue is present in joi 5.1.0 installed with npm.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
breaking changesChange that can breaking existing codeChange that can breaking existing codebugBug or defectBug or defect