-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
bugBug or defectBug or defectfeatureNew functionality or improvementNew functionality or improvement
Milestone
Description
Context
- node version: v8.11.4
- joi version: v14.0.0+
- environment (node, browser): node
- used with (hapi, standalone, ...): standalone
- any other relevant information: Schema below works with v13. We upgraded Joi and some of our tests failed.
What are you trying to achieve or the steps to reproduce ?
const schema = Joi.object().keys({
'mail.from': Joi.string().lowercase().email().optional(),
'mail.url': Joi.string().uri({ scheme: ['https'] }).optional(),
}).xor(
'mail.from',
'mail.url',
);
Joi.validate({ 'mail.url': 'https://example.com' }, schema));Removing .xor() seems to fix the validation.
Which result you had ?
{ error:
{ ValidationError: "value" must contain at least one of [mail.from, mail.url]
at Object.exports.process (node_modules/joi/lib/errors.js:201:19)
at internals.Object._validateWithOptions (node_modules/joi/lib/types/any/index.js:722:31)
at module.exports.internals.Any.root.validate node_modules/joi/lib/index.js:146:23)
at Object.<anonymous> (joi.js:13:17)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
isJoi: true,
name: 'ValidationError',
details: [ [Object] ],
_object: { 'mail.url': 'https://example.com' },
annotate: [Function] },
value: { 'mail.url': 'https://example.com' },
then: [Function: then],
catch: [Function: catch] }What did you expect ?
{ error: null,
value: { 'mail.url': 'https://example.com' },
then: [Function: then],
catch: [Function: catch] }Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugBug or defectBug or defectfeatureNew functionality or improvementNew functionality or improvement