mirror of https://github.com/node-red/node-red.git
Added validation logic to Change editor for validity of regular expressions
This change adds input validation to the gui of Change Nodes to prevent the user from unintentionally entering an invalid regular expression. The user will be notified on the specific error code to help resolve the issue.pull/121/head
parent
655e777a3e
commit
a03b4e4dd4
|
@ -56,7 +56,18 @@
|
|||
defaults: {
|
||||
action: {value:"change",required:true},
|
||||
property: {value:"payload"},
|
||||
from: {value:""},
|
||||
from: {value:"",validate: function(v) {
|
||||
if (this.action == "change") {
|
||||
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:""},
|
||||
name: {value:""}
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue