-
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: v4.3.0 and v4.4.4
- joi version: 8.1.0 and 9.0.0-0
- environment (node, browser): node
- used with (hapi, standalone, ...): standalone
- any other relevant information: none
What are you trying to achieve or the steps to reproduce ?
Call the validate function on the schema directly, without specifying a callback, but supplying an options object.
const Joi = require('joi');
const schema = Joi.any();
// Works
Joi.validate('test', { presence: 'optional' });
// Works
schema.validate('test');
// Throws
schema.validate('test', { presence: 'optional' });Which result you had ?
I get the following error message:
joi/lib/any.js:666
return callback(errors, result.value);
^
TypeError: callback is not a function
at internals.Any.applyFunctionToChildren.internals.Any.validate (/tmp/testapp/node_modules/joi/lib/any.js:666:16)
What did you expect ?
The validate function should work the same way in both cases (Joi.validate and schema.validate).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
featureNew functionality or improvementNew functionality or improvement