Skip to content

Commit 6530304

Browse files
committed
fix error, schema.validate
1 parent 663e1e8 commit 6530304

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/common/logger.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,14 @@ logger.decorateWithValidators = function (service) {
143143
service[name] = async function () {
144144
const args = Array.prototype.slice.call(arguments);
145145
const value = _combineObject(params, args);
146-
const normalized = Joi.attempt(value, method.schema);
146+
147+
// Convert plain object schema to Joi schema if needed
148+
let schema = method.schema;
149+
if (schema && !schema.validate && typeof schema === 'object') {
150+
schema = Joi.object().keys(schema);
151+
}
152+
153+
const normalized = Joi.attempt(value, schema);
147154

148155
const newArgs = [];
149156
// Joi will normalize values

0 commit comments

Comments
 (0)