From 5ac50fae3a927473bd2364c9e103731d23880dc2 Mon Sep 17 00:00:00 2001 From: ralphwetzel Date: Tue, 26 Sep 2023 20:00:48 +0200 Subject: [PATCH] Extend typedInput "num" type validity check to NaN, binary, octal & hex --- .../@node-red/editor-client/src/js/ui/common/typedInput.js | 4 +++- .../node_modules/@node-red/editor-client/src/js/ui/utils.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/common/typedInput.js b/packages/node_modules/@node-red/editor-client/src/js/ui/common/typedInput.js index 7440b464e7..9aa27c7100 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/common/typedInput.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/common/typedInput.js @@ -182,7 +182,9 @@ valueLabel: contextLabel }, str: {value:"str",label:"string",icon:"red/images/typedInput/az.svg"}, - num: {value:"num",label:"number",icon:"red/images/typedInput/09.svg",validate:/^[+-]?[0-9]*\.?[0-9]*([eE][-+]?[0-9]+)?$/}, + num: {value:"num",label:"number",icon:"red/images/typedInput/09.svg",validate: function(v) { + return (true === RED.utils.validateTypedProperty(v, "num")); + } }, bool: {value:"bool",label:"boolean",icon:"red/images/typedInput/bool.svg",options:["true","false"]}, json: { value:"json", 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 b08448e238..6475b19f5d 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 @@ -921,7 +921,7 @@ RED.utils = (function() { error = RED._("validator.errors.invalid-prop") } } else if (propertyType === 'num') { - if (!/^[+-]?[0-9]*\.?[0-9]*([eE][-+]?[0-9]+)?$/.test(propertyValue)) { + if (!/^NaN$|^[+-]?[0-9]*\.?[0-9]*([eE][-+]?[0-9]+)?$|^[+-]?(0b|0B)[01]+$|^[+-]?(0o|0O)[0-7]+$|^[+-]?(0x|0X)[0-9a-fA-F]+$/.test(propertyValue)) { error = RED._("validator.errors.invalid-num") } } else if (propertyType === 'jsonata') {