diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/utils.js b/packages/node_modules/@node-red/editor-client/src/js/ui/utils.js index 6475b19f5..bdc6a06d2 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/utils.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/utils.js @@ -906,7 +906,10 @@ RED.utils = (function() { * @returns true if valid, String if invalid */ function validateTypedProperty(propertyValue, propertyType, opt) { - + if (propertyValue && /^\${[^}]+}$/.test(propertyValue)) { + // Allow ${ENV_VAR} value + return true + } let error if (propertyType === 'json') { try { diff --git a/packages/node_modules/@node-red/editor-client/src/js/validators.js b/packages/node_modules/@node-red/editor-client/src/js/validators.js index 1673495aa..c17955ce1 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/validators.js +++ b/packages/node_modules/@node-red/editor-client/src/js/validators.js @@ -16,8 +16,20 @@ RED.validators = { number: function(blankAllowed,mopt){ return function(v, opt) { - if ((blankAllowed&&(v===''||v===undefined)) || (v!=='' && !isNaN(v))) { - return true; + if (blankAllowed && (v === '' || v === undefined)) { + return true + } + if (v !== '') { + if (/^NaN$|^[+-]?[0-9]*\.?[0-9]*([eE][-+]?[0-9]+)?$|^[+-]?(0b|0B)[01]+$|^[+-]?(0o|0O)[0-7]+$|^[+-]?(0x|0X)[0-9a-fA-F]+$/.test(v)) { + return true + } + if (/^\${[^}]+}$/.test(v)) { + // Allow ${ENV_VAR} value + return true + } + } + if (!isNaN(v)) { + return true } if (opt && opt.label) { return RED._("validator.errors.invalid-num-prop", { 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 d50725d51..5895220d3 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 @@ -227,34 +227,42 @@ name: {value:""}, props:{value:[{p:"payload"},{p:"topic",vt:"str"}], validate:function(v, opt) { if (!v || v.length === 0) { return true } + const errors = [] for (var i=0;i 0) { + return errors + } return true; } }, repeat: { value:"", validate: function(v, opt) { if ((v === "") || - (RED.validators.number(v) && + (RED.validators.number()(v) && (v >= 0) && (v <= 2147483))) { return true; } @@ -263,7 +271,7 @@ }, crontab: {value:""}, once: {value:false}, - onceDelay: {value:0.1}, + onceDelay: {value:0.1, validate: RED.validators.number(true)}, topic: {value:""}, payload: {value:"", validate: RED.validators.typedInput("payloadType", false) }, payloadType: {value:"date"},