-
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 code
Milestone
Description
Context
- joi version:
@hapi/joi@16.0.0-rc2&joi@14.3.1
What are you trying to achieve or the steps to reproduce ?
Validate old schema:
const Joi = require('@hapi/joi');
const Joi14 = require('joi');
const schema = Joi14.number();
console.log(Joi.validate(1, schema));Which result you had ?
/Users/gil/test/joi/node_modules/@hapi/joi/lib/cast.js:73
throw err;
^
AssertionError [ERR_ASSERTION]: Cannot add other alternatives without at least one schema(_tests)
at new AssertionError (internal/assert.js:269:11)
at Object.exports.assert (/Users/gil/test/joi/node_modules/@hapi/hoek/lib/index.js:592:11)
at internals.Alternatives.try (/Users/gil/test/joi/node_modules/@hapi/joi/lib/types/alternatives.js:104:14)
at Object.exports.schema (/Users/gil/test/joi/node_modules/@hapi/joi/lib/cast.js:31:42)
at internals.Object.keys (/Users/gil/test/joi/node_modules/@hapi/joi/lib/types/object.js:401:35)
at Object.exports.schema (/Users/gil/test/joi/node_modules/@hapi/joi/lib/cast.js:42:29)
at Object.internals.appendPath (/Users/gil/test/joi/node_modules/@hapi/joi/lib/cast.js:66:24)
at Object.exports.schema (/Users/gil/test/joi/node_modules/@hapi/joi/lib/cast.js:15:26)
at module.exports.internals.Any.root.compile (/Users/gil/test/joi/node_modules/@hapi/joi/lib/index.js:176:21)
at module.exports.internals.Any.root.validate (/Users/gil/test/joi/node_modules/@hapi/joi/lib/index.js:161:29)
What did you expect ?
Either a successful validation by calling into the old joi logic, or a more descriptive thrown error.
Note that this is the way that Hapi currently validates schemas in routes, causing such an error whenever an old schema is passed.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
breaking changesChange that can breaking existing codeChange that can breaking existing code