Skip to content

Commit 0823d0e

Browse files
committed
fix an issue when validatiing collections
1 parent 82bbe39 commit 0823d0e

File tree

3 files changed

+46
-11
lines changed

3 files changed

+46
-11
lines changed

src/component.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ function addProperties(model, Class, classId) {
917917
}
918918
});
919919

920-
return true;
920+
return result;
921921
}
922922

923923
function _getRealCollection(coll, type) {
@@ -1021,7 +1021,7 @@ function addProperties(model, Class, classId) {
10211021
}
10221022
}
10231023
} else {
1024-
$log.invalidPropertyName(
1024+
$log.invalidCollectionItem(
10251025
this.id(),
10261026
this.constructor.name,
10271027
propertyName,

src/log.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,3 +1205,34 @@ exports.historyDocumentUpdated = function historyDocumentRemoved(
12051205
" collection)"
12061206
);
12071207
};
1208+
1209+
/**
1210+
* @method invalidCollectionItem
1211+
* @param {String} componentId id of the component
1212+
* @param {String} type the type defined by the schema
1213+
* @param {String} constructorName name of the component class
1214+
* @description Invalid class name for a component
1215+
*/
1216+
exports.invalidCollectionItem = function invalidCollectionItem(
1217+
id,
1218+
className,
1219+
propertyName,
1220+
propertyValue,
1221+
type
1222+
) {
1223+
var classInfo = '';
1224+
1225+
if (className !== 'Function') {
1226+
classInfo = " (" + className + " class)";
1227+
}
1228+
1229+
getLogger().warn(
1230+
"invalid property '" + propertyName + "' on component '" +
1231+
id +
1232+
"'" +
1233+
classInfo +
1234+
": expected type '" +
1235+
type
1236+
+ "' for all items of the collection '[" + propertyValue + "']"
1237+
);
1238+
};

src/metamodel.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,15 +1828,19 @@ exports.isValidType = function isValidType(value, typeName, isDocument) {
18281828
isValid = checkCustomSchema(value[i], typeName[0]);
18291829
break;
18301830
case exports.isClassName(typeName[0]):
1831-
if (
1832-
value[i] !== '' &&
1833-
value[i] !== null &&
1834-
typeof value[i] !== 'string'
1835-
) {
1836-
isValid = exports.inheritFrom(
1837-
getClassName(value[i]),
1838-
typeName[0]
1839-
);
1831+
if (!isDocument) {
1832+
if (
1833+
value[i] !== '' &&
1834+
value[i] !== null &&
1835+
typeof value[i] !== 'string'
1836+
) {
1837+
isValid = exports.inheritFrom(
1838+
getClassName(value[i]),
1839+
typeName[0]
1840+
);
1841+
}
1842+
} else {
1843+
isValid = false;
18401844
}
18411845
break;
18421846
default:

0 commit comments

Comments
 (0)