Fix crash on repeated inject of invalid json payload

This commit is contained in:
Nick O'Leary
2016-02-26 10:35:15 +00:00
parent 0d1543ee8a
commit 859a7538e1
2 changed files with 31 additions and 12 deletions

View File

@@ -172,7 +172,22 @@
defaults: {
name: {value:""},
topic: {value:""},
payload: {value:""},
payload: {value:"", validate:function(v) {
var ptype = $("#node-input-payloadType").val() || this.payloadType;
if (ptype === 'json') {
try {
JSON.parse(v);
return true;
} catch(err) {
return false;
}
} else if (ptype === 'flow' || ptype === 'global' ) {
return /^[a-zA-Z_][a-zA-Z0-9_]*(\.[a-zA-Z_][a-zA-Z0-9_]+)*/i.test(v);
} else if (ptype === 'num') {
return /^[+-]?[0-9]*\.?[0-9]*([eE][-+]?[0-9]+)?$/.test(v);
}
return true;
}},
payloadType: {value:"date"},
repeat: {value:""},
crontab: {value:""},