let setMessageProperty return success flag

so calling node can warn if operation tries to overwrite primitive type
This commit is contained in:
Dave Conway-Jones
2020-01-26 18:20:25 +00:00
parent 9d4238e5cc
commit d5d9ac5c76
3 changed files with 17 additions and 3 deletions

View File

@@ -215,7 +215,9 @@ module.exports = function(RED) {
if (rule.t === 'delete') {
RED.util.setMessageProperty(msg,property,undefined);
} else if (rule.t === 'set') {
RED.util.setMessageProperty(msg,property,value);
if (!RED.util.setMessageProperty(msg,property,value)) {
node.warn(RED._("change.errors.no-override",{prop:property}));
}
} else if (rule.t === 'change') {
current = RED.util.getMessageProperty(msg,property);
if (typeof current === 'string') {

View File

@@ -657,7 +657,8 @@
"errors": {
"invalid-from": "Invalid 'from' property: __error__",
"invalid-json": "Invalid 'to' JSON property",
"invalid-expr": "Invalid JSONata expression: __error__"
"invalid-expr": "Invalid JSONata expression: __error__",
"no-override": "Can't overwrite primitive type with object __prop__."
}
},
"range": {