Skip to content

Commit b40e83a

Browse files
committed
fix an issue on component model validation
1 parent 7752ba7 commit b40e83a

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/component.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,9 +1034,7 @@ function addProperties(model, Class, classId) {
10341034
propertyValue = new Date(component[propertyName]);
10351035
break;
10361036
case propertyType === 'json':
1037-
propertyValue = JSON.parse(
1038-
JSON.stringify(component[propertyName])
1039-
);
1037+
propertyValue = component[propertyName];
10401038
break;
10411039
case propertyType === 'array':
10421040
propertyValue = new _Array({
@@ -1362,9 +1360,7 @@ function addStructure(path, name, model, id) {
13621360
);
13631361
break;
13641362
case propertyType === 'json':
1365-
propertyValue = JSON.parse(
1366-
JSON.stringify(getStructureValue(model, id, fullPath))
1367-
);
1363+
propertyValue = getStructureValue(model, id, fullPath);
13681364
break;
13691365
case $metamodel.isStructure(fullPath, model):
13701366
propertyValue = addStructure(

src/metamodel.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,18 +1957,23 @@ exports.isValidType = function isValidType(value, typeName) {
19571957
* @description Check if an object is compliant with a class
19581958
*/
19591959
function _checkClassName(value, typeName) {
1960-
var isValid = true;
1960+
var isValid = false;
19611961
var typeRef = getRealClassName(typeName);
19621962
var component = value;
19631963

19641964
if (value !== '' && value !== null) {
19651965
if (hasType(value, 'string')) {
19661966
component = $component.get(value);
19671967
}
1968-
if (getClassName(component) !== typeRef && component.id) {
1969-
isValid = false;
1970-
$log.invalidClassType(value, typeName);
1968+
if (getClassName(component) === typeRef && component && component.id) {
1969+
isValid = true;
19711970
}
1971+
} else {
1972+
isValid = true;
1973+
}
1974+
1975+
if (!isValid) {
1976+
$log.invalidClassType(value, typeName);
19721977
}
19731978
return isValid;
19741979
}

0 commit comments

Comments
 (0)