diff --git a/editor/js/validators.js b/editor/js/validators.js index 821593b79..d7357e66d 100644 --- a/editor/js/validators.js +++ b/editor/js/validators.js @@ -16,8 +16,8 @@ RED.validators = { number: function(){return function(v) { return v!=='' && !isNaN(v);}}, regex: function(re){return function(v) { return re.test(v);}}, - typedInput: function(ptypeName) { return function(v) { - var ptype = $("#node-input-"+ptypeName).val() || this[ptypeName]; + typedInput: function(ptypeName,isConfig) { return function(v) { + var ptype = $("#node-"+(isConfig?"config-":"")+"input-"+ptypeName).val() || this[ptypeName]; if (ptype === 'json') { try { JSON.parse(v); @@ -25,7 +25,7 @@ RED.validators = { } catch(err) { return false; } - } else if (ptype === 'flow' || ptype === 'global' ) { + } else if (ptype === 'msg' || ptype === 'flow' || ptype === 'global' ) { return RED.utils.validatePropertyExpression(v); } else if (ptype === 'num') { return /^[+-]?[0-9]*\.?[0-9]*([eE][-+]?[0-9]+)?$/.test(v); diff --git a/nodes/core/core/80-template.html b/nodes/core/core/80-template.html index 0bbf4da42..9dc2997b8 100644 --- a/nodes/core/core/80-template.html +++ b/nodes/core/core/80-template.html @@ -78,7 +78,7 @@ category: 'function', defaults: { name: {value:""}, - field: {value:"payload"}, + field: {value:"payload", validate: RED.validators.typedInput("fieldType")}, fieldType: {value:"msg"}, format: {value:"handlebars"}, syntax: {value:"mustache"}, diff --git a/nodes/core/core/89-trigger.html b/nodes/core/core/89-trigger.html index e70fe49bf..61770ebd6 100644 --- a/nodes/core/core/89-trigger.html +++ b/nodes/core/core/89-trigger.html @@ -85,8 +85,8 @@ category: 'function', color:"#E6E0F8", defaults: { - op1: {value:"1"}, - op2: {value:"0"}, + op1: {value:"1", validate: RED.validators.typedInput("op1type")}, + op2: {value:"0", validate: RED.validators.typedInput("op2type")}, op1type: {value:"val"}, op2type: {value:"val"}, duration: {value:"250",required:true,validate:RED.validators.number()}, diff --git a/nodes/core/logic/10-switch.html b/nodes/core/logic/10-switch.html index 3ce53c89f..dfba1bae1 100644 --- a/nodes/core/logic/10-switch.html +++ b/nodes/core/logic/10-switch.html @@ -48,7 +48,7 @@ category: 'function', defaults: { name: {value:""}, - property: {value:"payload", required:true}, + property: {value:"payload", required:true, validate: RED.validators.typedInput("propertyType")}, propertyType: { value:"msg" }, rules: {value:[{t:"eq", v:""}]}, checkall: {value:"true", required:true}, diff --git a/nodes/core/logic/17-split.html b/nodes/core/logic/17-split.html index 2cc82a143..efa15cc9c 100644 --- a/nodes/core/logic/17-split.html +++ b/nodes/core/logic/17-split.html @@ -162,7 +162,7 @@ name: {value:""}, mode: {value:"auto"}, build: { value:"string"}, - property: { value: "payload"}, + property: { value: "payload", validate: RED.validators.typedInput("propertyType")}, propertyType: { value:"msg"}, key: {value:"topic"}, joiner: { value:"\\n"},