mirror of
https://github.com/node-red/node-red.git
synced 2025-12-27 07:31:07 +01:00
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
This commit is contained in:
@@ -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 }))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user