Skip to content

Commit e0f3f18

Browse files
committed
Improve metamodel validation (#61)
1 parent 3a8dad0 commit e0f3f18

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

src/metamodel.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2103,17 +2103,21 @@ exports.isValidObject = function isValidObject(
21032103
for (fieldName in object) {
21042104
field = object[fieldName];
21052105

2106-
if (!hasType(schema[fieldName], 'undefined') || fieldName === '_core') {
2107-
// case of _core
2108-
if (fieldName !== '_core') {
2109-
typeSchema = schema[fieldName].type;
2110-
} else {
2111-
typeSchema = 'boolean';
2112-
}
2113-
2114-
// cas of _id
2115-
if (fieldName === '_id') {
2116-
typeSchema = 'string';
2106+
if (
2107+
!hasType(schema[fieldName], 'undefined') ||
2108+
fieldName === '_core' ||
2109+
fieldName === '_id'
2110+
) {
2111+
switch (true) {
2112+
case fieldName === '_core':
2113+
typeSchema = 'boolean';
2114+
break;
2115+
case fieldName === '_id':
2116+
typeSchema = 'string';
2117+
break;
2118+
default:
2119+
typeSchema = schema[fieldName].type;
2120+
break;
21172121
}
21182122
} else {
21192123
if (strict) {

0 commit comments

Comments
 (0)