1
0
Fork 0

Wrap non-Joi objects as Joi schemas.

This commit is contained in:
Alan Plum 2014-10-21 17:20:30 +02:00
parent 233f21662a
commit 2747bf8b04
1 changed files with 3 additions and 1 deletions

View File

@ -269,7 +269,9 @@ _.extend(Model.prototype, {
metadataSchema[attributeName] || metadataSchema[attributeName] ||
joi.forbidden() joi.forbidden()
), ),
result = schema.validate(value); result = (
schema.isJoi ? schema : joi.object().keys(schema)
).validate(value);
if (result.error) { if (result.error) {
this.errors[attributeName] = result.error; this.errors[attributeName] = result.error;