mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Updated logic to handle when parts of the msg object are changed to strings
This commit is contained in:
@@ -65,6 +65,21 @@ module.exports = class PayloadValidator {
|
||||
return _.set(object, location, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* lodash set will always pass but might not actually set the value
|
||||
* So here we test that it was actually set and use that to confirm we can set
|
||||
*
|
||||
* @param {*} object
|
||||
* @param {*} location
|
||||
* @returns
|
||||
*/
|
||||
canSet(object, location) {
|
||||
const test = 'test';
|
||||
let clonedObject = clone(object);
|
||||
clonedObject = this.setValue(clonedObject, location, test);
|
||||
return test === this.getValue(clonedObject, location);
|
||||
}
|
||||
|
||||
check(_after) {
|
||||
let after = _after;
|
||||
try {
|
||||
@@ -85,6 +100,10 @@ module.exports = class PayloadValidator {
|
||||
details,
|
||||
conversationId: this.conversationId
|
||||
});
|
||||
|
||||
if (!this.canSet(after, location)) {
|
||||
throw new Error(`Cant set value as ${location} is no longer present in after`);
|
||||
}
|
||||
after = this.setValue(after, location, beforeValue);
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user