From 48a528a4b8c7d431fd46dc1dc0e5efd16fc3555a Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Tue, 26 Apr 2022 13:45:14 +0100 Subject: [PATCH] Ensure property validation is backwards compatible --- .../@node-red/editor-client/src/js/ui/editor.js | 6 +++++- .../@node-red/nodes/core/common/20-inject.html | 10 +++++++--- .../@node-red/nodes/locales/en-US/messages.json | 8 ++++---- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/editor.js b/packages/node_modules/@node-red/editor-client/src/js/ui/editor.js index 4d4eab84b..f0f3a073b 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/editor.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/editor.js @@ -128,7 +128,7 @@ RED.editor = (function() { * @param definition - the node property definitions (either def.defaults or def.creds) * @param property - the property name being validated * @param value - the property value being validated - * @returns {boolean} whether the node proprty is valid + * @returns {boolean|string} whether the node proprty is valid. `true`: valid `false|String`: invalid */ function validateNodeProperty(node,definition,property,value) { var valid = true; @@ -165,6 +165,10 @@ RED.editor = (function() { if ((definition[property].validate.length === 2) && ((typeof valid) === "string")) { return valid; + } else { + // Otherwise, a 2.x returns a truth-like/false-like value that + // we should cooerce to a boolean. + valid = !!valid } } catch(err) { console.log("Validation error:",node.type,node.id,"property: "+property,"value:",value,err); diff --git a/packages/node_modules/@node-red/nodes/core/common/20-inject.html b/packages/node_modules/@node-red/nodes/core/common/20-inject.html index 9f4ee07e0..4811d3ae5 100644 --- a/packages/node_modules/@node-red/nodes/core/common/20-inject.html +++ b/packages/node_modules/@node-red/nodes/core/common/20-inject.html @@ -230,17 +230,21 @@ for (var i=0;i