1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Flag validation errors in Inject node props config

Fixes #2914
This commit is contained in:
Nick O'Leary 2021-04-06 16:45:21 +01:00
parent 74b547b93c
commit ca5e45a46d
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -163,12 +163,27 @@
$("#node-input-property-container").editableList('height',height);
}
RED.nodes.registerType('inject',{
RED.nodes.registerType('inject',{  
category: 'common',
color:"#a6bbcf",
defaults: {
name: {value:""},
props:{value:[{p:"payload"},{p:"topic",vt:"str"}]},
props:{value:[{p:"payload"},{p:"topic",vt:"str"}], validate:function(v) {
if (!v || v.length === 0) { return true }
for (var i=0;i<v.length;i++) {
if (/msg|flow|global/.test(v[i].vt)) {
if (!RED.utils.validatePropertyExpression(v[i].v)) {
return false;
}
} else if (v[i].vt === "jsonata") {
try{jsonata(v[i].v);}catch(e){return false;}
} else if ([i].vt === "json") {
try{JSON.parse(v[i].v);}catch(e){return false;}
}
}
return true;
}
},
repeat: {value:"", validate:function(v) { return ((v === "") || (RED.validators.number(v) && (v >= 0) && (v <= 2147483))) }},
crontab: {value:""},
once: {value:false},