From a03b4e4dd43f57bc5209ccbf3e65f545f44e76c7 Mon Sep 17 00:00:00 2001 From: Frank van de Pol Date: Sun, 22 Dec 2013 17:46:25 +0100 Subject: [PATCH] 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. --- nodes/core/logic/15-change.html | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/nodes/core/logic/15-change.html b/nodes/core/logic/15-change.html index ea360908f..b1ad880d8 100644 --- a/nodes/core/logic/15-change.html +++ b/nodes/core/logic/15-change.html @@ -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("Error: "+err.message,"error"); + return false; + } + } + return true; + }}, to: {value:""}, name: {value:""} },