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

Add validation to Change node editor for invalid regex

This change adds input validation to the gui of Change Nodes to prevent
the user from unintentionally entering an invalid regular expression
(in case the ‘use regular expressions’  option is enabled).

The user will be notified (using the RED notification mechanism) on the
specific error code to help resolve the issue.
This commit is contained in:
Frank van de Pol 2013-12-24 20:28:08 +01:00
parent b411d59d43
commit 1ebc5979aa

View File

@ -61,7 +61,18 @@
defaults: {
action: {value:"change",required:true},
property: {value:"payload"},
from: {value:""},
from: {value:"",validate: function(v) {
if (this.action == "change" && this.reg) {
try {
var re = new RegExp(this.from, "g");
return true;
} catch(err) {
RED.notify("<strong>Error</strong>: "+err.message,"error");
return false;
}
}
return true;
}},
to: {value:""},
reg: {value:false},
name: {value:""}