From 1eb6056843faa54b1afb11c7874757c131b0a611 Mon Sep 17 00:00:00 2001 From: ZJ van de Weg Date: Mon, 7 Jul 2025 16:19:34 +0200 Subject: [PATCH] Fix inject node validation to support binary and hexadecimal numbers The inject node was using a restrictive regex that only accepted decimal numbers, while the switch node properly supported binary (0b) and hexadecimal (0x) formats. This inconsistency caused the inject node to show validation errors for valid number formats. Updated the inject node to use the same validateTypedProperty utility function as the switch node, ensuring consistent number validation across both nodes. Fixes #5208 --- .../node_modules/@node-red/nodes/core/common/20-inject.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 5895220d3..032730be4 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 @@ -248,8 +248,9 @@ errors.push(RED._("node-red:inject.errors.invalid-json", { prop: 'msg.'+v[i].p, error: e.message })) } } else if (v[i].vt === "num"){ - if (!/^[+-]?[0-9]*\.?[0-9]*([eE][-+]?[0-9]+)?$/.test(v[i].v)) { - errors.push(RED._("node-red:inject.errors.invalid-prop", { prop: 'msg.'+v[i].p, error: v[i].v })) + const numValidation = RED.utils.validateTypedProperty(v[i].v, 'num', { prop: 'msg.'+v[i].p }); + if (numValidation !== true) { + errors.push(numValidation || RED._("node-red:inject.errors.invalid-prop", { prop: 'msg.'+v[i].p, error: v[i].v })) } } }