Skip to content

Commit 8b77ca6

Browse files
committed
Fixed schema validation.
1 parent 3dccad5 commit 8b77ca6

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

utils.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2096,7 +2096,21 @@ exports.validate_builder = function(model, error, schema, collection, path, inde
20962096

20972097
if (TYPE.type === 7) {
20982098
// Another schema
2099-
exports.validate_builder(value, error, TYPE.raw, collection, current + name, undefined, undefined, pluspath);
2099+
result = TYPE.validate ? TYPE.validate(value, model) : null;
2100+
if (result == null)
2101+
exports.validate_builder(value, error, TYPE.raw, collection, current + name, undefined, undefined, pluspath);
2102+
else {
2103+
type = typeof(result);
2104+
if (type === 'string') {
2105+
if (result[0] === '@')
2106+
error.push(pluspath + name, '@', current + name, index, entity.resourcePrefix + result.substring(1));
2107+
else
2108+
error.push(pluspath + name, result, current + name, index, prefix);
2109+
} else if (type === 'boolean') {
2110+
!result && error.push(pluspath + name, '@', current + name, index, prefix);
2111+
} else if (result.isValid === false)
2112+
error.push(pluspath + name, result.error, current + name, index, prefix);
2113+
}
21002114
continue;
21012115
}
21022116

0 commit comments

Comments
 (0)