-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
featureNew functionality or improvementNew functionality or improvement
Milestone
Description
Context
- node version: 7.10.
- joi version: 10.6.0
- environment: node
- used with: standalone
What are you trying to achieve or the steps to reproduce ?
const joi = require('joi');
const ourJoi = joi.extend({
base: joi.string(),
name: 'string',
language: {
// Note: Missing translation here!
},
rules: [
{
name: 'something',
validate (params, value, state, options) {
if (value !== '0') {
return this.createError('string.something', {
v: value,
}, state, options);
}
return value;
},
},
],
});
ourJoi.validate('test', ourJoi.string().something()); // <<<< Error HereWhich result you had ?
Upon using the rule via .validate an error gets thrown.
TypeError: Cannot read property 'length' of undefined
at Object.toString (XXX/node_modules/joi/lib/errors.js:100:31)
at processErrors (XXX/node_modules/joi/lib/errors.js:153:36)
at Object.exports.process (XXX/node_modules/joi/lib/errors.js:176:22)
at type._validateWithOptions (XXX/node_modules/joi/lib/types/any/index.js:651:31)
at Object.root.validate (XXX/node_modules/joi/lib/index.js:121:23)
What did you expect ?
I would expect to get an error upon calling extend telling me that the language entry is required.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
featureNew functionality or improvementNew functionality or improvement