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

Merge pull request #3549 from node-red/pr_3438

Add support of property validation message
This commit is contained in:
Nick O'Leary 2022-04-26 13:53:50 +01:00 committed by GitHub
commit 62e730b621
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 656 additions and 141 deletions

View File

@ -1162,5 +1162,21 @@
"ru": "Russian",
"zh-CN": "Chinese(Simplified)",
"zh-TW": "Chinese(Traditional)"
},
"validator": {
"errors": {
"invalid-json": "Invalid JSON data: __error__",
"invalid-json-prop": "__prop__: invalid JSON data: __error__",
"invalid-prop": "Invalid property expression",
"invalid-prop-prop": "__prop__: invalid property expression",
"invalid-num": "Invalid number",
"invalid-num-prop": "__prop__: invalid number",
"invalid-regexp": "Invalid input pattern",
"invalid-regex-prop": "__prop__: invalid input pattern",
"missing-required-prop": "__prop__: property value missing",
"invalid-config": "__prop__: invalid configuration node",
"missing-config": "__prop__: missing configuration node",
"validation-error": "__prop__: validation error: __node__, __id__: __error__"
}
}
}

View File

@ -1299,5 +1299,21 @@
"zoom-out": "ズームアウト",
"zoom-reset": "ズームリセット",
"toggle-navigator": "ナビゲータ表示切替"
},
"validator": {
"errors": {
"invalid-json": "JSONデータが不正: __error__",
"invalid-json-prop": "__prop__: JSONデータが不正: __error__",
"invalid-prop": "プロパティ式が不正",
"invalid-prop-prop": "__prop__: プロパティ式が不正",
"invalid-num": "数値が不正",
"invalid-num-prop": "__prop__: 数値が不正",
"invalid-regexp": "入力パターンが不正",
"invalid-regex-prop": "__prop__: 入力パターンが不正",
"missing-required-prop": "__prop__: プロパティが未設定",
"invalid-config": "__prop__: 設定ノードが不正",
"missing-config": "__prop__: 設定ノードが存在しません",
"validation-error": "__prop__: チェックエラー: __node__, __id__: __error__"
}
}
}

View File

@ -359,6 +359,7 @@ RED.popover = (function() {
setTimeout(closePopup,delay.hide);
}
});
if (trigger === 'hover') {
target.on('mouseenter',function(e) {
clearTimeout(timer);
@ -470,6 +471,10 @@ RED.popover = (function() {
popover.setAction = function(newAction) {
action = newAction;
}
popover.delete = function() {
target.off("mouseenter");
target.off("mouseleave");
};
return popover;
},

View File

@ -110,7 +110,11 @@ RED.editor = (function() {
var result = [];
for (var prop in definition) {
if (definition.hasOwnProperty(prop)) {
if (!validateNodeProperty(node, definition, prop, properties[prop])) {
var valid = validateNodeProperty(node, definition, prop, properties[prop]);
if ((typeof valid) === "string") {
result.push(valid);
}
else if(!valid) {
result.push(prop);
}
}
@ -124,7 +128,7 @@ RED.editor = (function() {
* @param definition - the node property definitions (either def.defaults or def.creds)
* @param property - the property name being validated
* @param value - the property value being validated
* @returns {boolean} whether the node proprty is valid
* @returns {boolean|string} whether the node proprty is valid. `true`: valid `false|String`: invalid
*/
function validateNodeProperty(node,definition,property,value) {
var valid = true;
@ -136,22 +140,74 @@ RED.editor = (function() {
if (/^\$\{[a-zA-Z_][a-zA-Z0-9_]*\}$/.test(value)) {
return true;
}
var label = null;
if (("label" in definition[property]) &&
((typeof definition[property].label) == "string")) {
label = definition[property].label;
}
if ("required" in definition[property] && definition[property].required) {
valid = value !== "";
if (!valid && label) {
return RED._("validator.errors.missing-required-prop", {
prop: label
});
}
}
if (valid && "validate" in definition[property]) {
try {
valid = definition[property].validate.call(node,value);
var opt = {};
if (label) {
opt.label = label;
}
valid = definition[property].validate.call(node,value, opt);
// If the validator takes two arguments, it is a 3.x validator that
// can return a String to mean 'invalid' and provide a reason
if ((definition[property].validate.length === 2) &&
((typeof valid) === "string")) {
return valid;
} else {
// Otherwise, a 2.x returns a truth-like/false-like value that
// we should cooerce to a boolean.
valid = !!valid
}
} catch(err) {
console.log("Validation error:",node.type,node.id,"property: "+property,"value:",value,err);
return RED._("validator.errors.validation-error", {
prop: property,
node: node.type,
id: node.id,
error: err.message
});
}
}
if (valid && definition[property].type && RED.nodes.getType(definition[property].type) && !("validate" in definition[property])) {
if (!value || value == "_ADD_") {
valid = definition[property].hasOwnProperty("required") && !definition[property].required;
if (!valid && label) {
return RED._("validator.errors.missing-required-prop", {
prop: label
});
}
} else {
var configNode = RED.nodes.node(value);
valid = (configNode && (configNode.valid == null || configNode.valid));
if (configNode) {
if ((configNode.valid == null) || configNode.valid) {
return true;
}
if (label) {
return RED._("validator.errors.invalid-config", {
prop: label
});
}
}
else {
if (label) {
return RED._("validator.errors.missing-config", {
prop: label
});
}
}
return false;
}
}
return valid;
@ -179,10 +235,26 @@ RED.editor = (function() {
if (defaults[property].hasOwnProperty("format") && defaults[property].format !== "" && input[0].nodeName === "DIV") {
value = input.text();
}
if (!validateNodeProperty(node, defaults, property,value)) {
var valid = validateNodeProperty(node, defaults, property,value);
if (((typeof valid) === "string") || !valid) {
input.addClass("input-error");
if ((typeof valid) === "string") {
var tooltip = input.data("tooltip");
if (tooltip) {
tooltip.setContent(valid);
}
else {
tooltip = RED.popover.tooltip(input, valid);
input.data("tooltip", tooltip);
}
}
} else {
input.removeClass("input-error");
var tooltip = input.data("tooltip");
if (tooltip) {
input.data("tooltip", null);
tooltip.delete();
}
}
}
}

View File

@ -14,22 +14,72 @@
* limitations under the License.
**/
RED.validators = {
number: function(blankAllowed){return function(v) { return (blankAllowed&&(v===''||v===undefined)) || (v!=='' && !isNaN(v));}},
regex: function(re){return function(v) { return re.test(v);}},
typedInput: function(ptypeName,isConfig) { return function(v) {
var ptype = $("#node-"+(isConfig?"config-":"")+"input-"+ptypeName).val() || this[ptypeName];
if (ptype === 'json') {
try {
JSON.parse(v);
number: function(blankAllowed,mopt){
return function(v, opt) {
if ((blankAllowed&&(v===''||v===undefined)) || (v!=='' && !isNaN(v))) {
return true;
} catch(err) {
return false;
}
} 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);
}
return true;
}}
if (opt && opt.label) {
return RED._("validator.errors.invalid-num-prop", {
prop: opt.label
});
}
return opt ? RED._("validator.errors.invalid-num") : false;
};
},
regex: function(re, mopt) {
return function(v, opt) {
if (re.test(v)) {
return true;
}
if (opt && opt.label) {
return RED._("validator.errors.invalid-regex-prop", {
prop: opt.label
});
}
return opt ? RED._("validator.errors.invalid-regexp") : false;
};
},
typedInput: function(ptypeName,isConfig,mopt) {
return function(v, opt) {
var ptype = $("#node-"+(isConfig?"config-":"")+"input-"+ptypeName).val() || this[ptypeName];
if (ptype === 'json') {
try {
JSON.parse(v);
return true;
} catch(err) {
if (opt && opt.label) {
return RED._("validator.errors.invalid-json-prop", {
error: err.message,
prop: opt.label,
});
}
return opt ? RED._("validator.errors.invalid-json", {
error: err.message
}) : false;
}
} else if (ptype === 'msg' || ptype === 'flow' || ptype === 'global' ) {
if (RED.utils.validatePropertyExpression(v)) {
return true;
}
if (opt && opt.label) {
return RED._("validator.errors.invalid-prop-prop", {
prop: opt.label
});
}
return opt ? RED._("validator.errors.invalid-prop") : false;
} else if (ptype === 'num') {
if (/^[+-]?[0-9]*\.?[0-9]*([eE][-+]?[0-9]+)?$/.test(v)) {
return true;
}
if (opt && opt.label) {
return RED._("validator.errors.invalid-num-prop", {
prop: opt.label
});
}
return opt ? RED._("validator.errors.invalid-num") : false;
}
return true;
};
}
};

View File

@ -225,28 +225,47 @@
color:"#a6bbcf",
defaults: {
name: {value:""},
props:{value:[{p:"payload"},{p:"topic",vt:"str"}], validate:function(v) {
props:{value:[{p:"payload"},{p:"topic",vt:"str"}], validate:function(v, opt) {
if (!v || v.length === 0) { return true }
for (var i=0;i<v.length;i++) {
if (/msg|flow|global/.test(v[i].vt)) {
if (!RED.utils.validatePropertyExpression(v[i].v)) {
return false;
return RED._("node-red:inject.errors.invalid-prop", { prop: 'msg.'+v[i].p, error: v[i].v });
}
} else if (v[i].vt === "jsonata") {
try{jsonata(v[i].v);}catch(e){return false;}
try{ jsonata(v[i].v); }
catch(e){
return RED._("node-red:inject.errors.invalid-jsonata", { prop: 'msg.'+v[i].p, error: e.message });
}
} else if (v[i].vt === "json") {
try{JSON.parse(v[i].v);}catch(e){return false;}
try{ JSON.parse(v[i].v); }
catch(e){
return RED._("node-red:inject.errors.invalid-json", { prop: 'msg.'+v[i].p, error: e.message });
}
} else if (v[i].vt === "num"){
if (!/^[+-]?[0-9]*\.?[0-9]*([eE][-+]?[0-9]+)?$/.test(v[i].v)) {
return RED._("node-red:inject.errors.invalid-prop", { prop: 'msg.'+v[i].p, error: v[i].v });
}
}
}
return true;
}
},
repeat: {value:"", validate:function(v) { return ((v === "") || (RED.validators.number(v) && (v >= 0) && (v <= 2147483))) }},
repeat: {
value:"", validate: function(v, opt) {
if ((v === "") ||
(RED.validators.number(v) &&
(v >= 0) && (v <= 2147483))) {
return true;
}
return RED._("node-red:inject.errors.invalid-repeat");
}
},
crontab: {value:""},
once: {value:false},
onceDelay: {value:0.1},
topic: {value:""},
payload: {value:"", validate: RED.validators.typedInput("payloadType")},
payload: {value:"", validate: RED.validators.typedInput("payloadType", false) },
payloadType: {value:"date"},
},
icon: "inject.svg",

View File

@ -274,7 +274,11 @@
name: { value: "" },
links: { value: [], type:"link in[]" },
linkType: { value:"static" },
timeout: { value: "30", validate:RED.validators.number(true) }
timeout: {
value: "30",
label: RED._("node-red:link.timeout"),
validate:RED.validators.number(true)
}
},
inputs: 1,
outputs: 1,

View File

@ -358,24 +358,38 @@
name: {value:"_DEFAULT_"},
func: {value:"\nreturn msg;"},
outputs: {value:1},
noerr: {value:0,required:true,validate:function(v) { return !v; }},
noerr: {value:0,required:true,
validate: function(v, opt) {
if (!v) {
return true;
}
return RED._("node-red:function.error.invalid-js");
}},
initialize: {value:""},
finalize: {value:""},
libs: {value: [], validate: function(v) {
libs: {value: [], validate: function(v, opt) {
if (!v) { return true; }
for (var i=0,l=v.length;i<l;i++) {
var m = v[i];
if (!RED.utils.checkModuleAllowed(m.module,null,installAllowList,installDenyList)) {
return false
return RED._("node-red:function.error.moduleNotAllowed", {
module: m.module
});
}
if (m.var === "" || / /.test(m.var)) {
return false;
return RED._("node-red:function.error.moduleNameError", {
name: m.var
});
}
if (missingModules.indexOf(m.module) > -1) {
return false;
return RED._("node-red:function.error.missing-module", {
module: m.module
});
}
if (invalidModuleVNames.indexOf(m.var) !== -1){
return false;
return RED._("node-red:function.error.moduleNameError", {
name: m.var
});
}
}
return true;

View File

@ -163,7 +163,9 @@
category: 'function',
defaults: {
name: {value:""},
property: {value:"payload", required:true, validate: RED.validators.typedInput("propertyType")},
property: {value:"payload", required:true,
label:RED._("node-red:common.label.payload"),
validate: RED.validators.typedInput("propertyType", false)},
propertyType: { value:"msg" },
rules: {value:[{t:"eq", v:"", vt:"str"}]},
checkall: {value:"true", required:true},

View File

@ -19,38 +19,66 @@
<script type="text/javascript">
(function() {
function validateProperty(v,vt) {
function isInvalidProperty(v,vt) {
if (/msg|flow|global/.test(vt)) {
if (!RED.utils.validatePropertyExpression(v)) {
return false;
return RED._("node-red:change.errors.invalid-prop", {
property: v
});
}
} else if (vt === "jsonata") {
try{jsonata(v);}catch(e){return false;}
try{ jsonata(v); } catch(e) {
return RED._("node-red:change.errors.invalid-expr", {
error: e.message
});
}
} else if (vt === "json") {
try{JSON.parse(v);}catch(e){return false;}
try{ JSON.parse(v); } catch(e) {
return RED._("node-red:change.errors.invalid-json-data", {
error: e.message
});
}
}
return true;
return false;
}
RED.nodes.registerType('change', {
color: "#E2D96E",
category: 'function',
defaults: {
name: {value:""},
rules:{value:[{t:"set",p:"payload",pt:"msg",to:"",tot:"str"}],validate: function(rules) {
rules:{value:[{t:"set",p:"payload",pt:"msg",to:"",tot:"str"}],validate: function(rules, opt) {
var msg;
if (!rules || rules.length === 0) { return true }
for (var i=0;i<rules.length;i++) {
var r = rules[i];
if (r.t === 'set') {
if (!validateProperty(r.p,r.pt) || !validateProperty(r.to,r.tot)) {
return false;
if (msg = isInvalidProperty(r.p,r.pt)) {
return msg;
}
if (msg = isInvalidProperty(r.to,r.tot)) {
return msg;
}
} else if (r.t === 'change') {
if (!validateProperty(r.p,r.pt) || !validateProperty(r.from,r.fromt) || !validateProperty(r.to,r.tot)) {
return false;
if (msg = isInvalidProperty(r.p,r.pt)) {
return msg;
}
if(msg = isInvalidProperty(r.from,r.fromt)) {
return msg;
}
if(msg = isInvalidProperty(r.to,r.tot)) {
return msg;
}
} else if (r.t === 'delete') {
if (msg = isInvalidProperty(r.p,r.pt)) {
return msg;
}
} else if (r.t === 'move') {
if (!validateProperty(r.p,r.pt)) {
return false;
if (msg = isInvalidProperty(r.p,r.pt)) {
return msg;
}
if (msg = isInvalidProperty(r.to,r.tot)) {
return msg;
}
}
}

View File

@ -41,13 +41,22 @@
color: "#E2D96E",
category: 'function',
defaults: {
minin: {value:"",required:true,validate:RED.validators.number()},
maxin: {value:"",required:true,validate:RED.validators.number()},
minout: {value:"",required:true,validate:RED.validators.number()},
maxout: {value:"",required:true,validate:RED.validators.number()},
minin: {value:"", required: true,
label:RED._("node-red:range.label.minin"),
validate:RED.validators.number(false)},
maxin: {value:"", required: true,
label:RED._("node-red:range.label.maxin"),
validate:RED.validators.number(false)},
minout: {value:"", required:true,
label:RED._("node-red:range.label.minout"),
validate:RED.validators.number(false)},
maxout: {value:"", required:true,
label:RED._("node-red:range.label.maxout"),
validate:RED.validators.number(false)},
action: {value:"scale"},
round: {value:false},
property: {value:"payload",required:true},
property: {value:"payload",required:true,
label:RED._("node-red:common.label.property")},
name: {value:""}
},
inputs: 1,

View File

@ -56,7 +56,9 @@
category: 'function',
defaults: {
name: {value:""},
field: {value:"payload", validate:RED.validators.typedInput("fieldType")},
field: {value:"payload",
label:"payload",
validate:RED.validators.typedInput("fieldType", false)},
fieldType: {value:"msg"},
format: {value:"handlebars"},
syntax: {value:"mustache"},

View File

@ -111,14 +111,54 @@
defaults: {
name: {value:""},
pauseType: {value:"delay", required:true},
timeout: {value:"5", required:true, validate:function(v) { return RED.validators.number(v) && (v >= 0); }},
timeout: {
value:"5", required:true,
label:RED._("node-red:delay.label.delay"),
validate:function(v,opt) {
if (RED.validators.number(v) && (v >= 0)) {
return true;
}
return RED._("node-red:delay.errors.invalid-timeout");
}},
timeoutUnits: {value:"seconds"},
rate: {value:"1", required:true, validate:function(v) { return RED.validators.number(v) && (v >= 0); }},
nbRateUnits: {value:"1", required:false,
validate:function(v) { return v === undefined || (RED.validators.number(v) && (v >= 0)); }},
rate: {
value:"1",
required:true,
label:RED._("node-red:delay.label.rate"),
validate:function(v,opt) {
if (RED.validators.number(v) && (v >= 0)) {
return true;
}
return RED._("node-red:delay.errors.invalid-rate");
}
},
nbRateUnits: {
value:"1",
required:false,
validate:function(v,opt) {
if (v === undefined || (RED.validators.number(v) && (v >= 0))) {
return true;
}
return RED._("node-red:delay.errors.invalid-rate-unit");
}
},
rateUnits: {value: "second"},
randomFirst: {value:"1", required:true, validate:function(v) { return RED.validators.number(v) && (v >= 0); }},
randomLast: {value:"5", required:true, validate:function(v) { return RED.validators.number(v) && (v >= 0); }},
randomFirst: {
value:"1", required:true,
validate:function(v,opt) {
if (RED.validators.number(v) && (v >= 0)) {
return true;
}
return RED._("node-red:delay.errors.invalid-random-first");
}},
randomLast: {
value:"5", required:true,
validate:function(v,opt) {
if (RED.validators.number(v) && (v >= 0)) {
return true;
}
return RED._("node-red:delay.errors.invalid-random-last");
}},
randomUnits: {value: "seconds"},
drop: {value:false},
allowrate: {value:false},

View File

@ -87,17 +87,25 @@
color:"#E6E0F8",
defaults: {
name: {value:""},
op1: {value:"1", validate: RED.validators.typedInput("op1type")},
op2: {value:"0", validate: RED.validators.typedInput("op2type")},
op1: {value:"1",
label: RED._("node-red:trigger.send"),
validate: RED.validators.typedInput("op1type", false)},
op2: {value:"0",
label: RED._("node-red:trigger.then-send"),
validate: RED.validators.typedInput("op2type", false)},
op1type: {value:"val"},
op2type: {value:"val"},
duration: {value:"250",required:true,validate:RED.validators.number()},
duration: {
value:"250", required:true,
label:RED._("node-red:trigger.label.duration"),
validate:RED.validators.number(false)},
extend: {value:"false"},
overrideDelay: {value:"false"},
units: {value:"ms"},
reset: {value:""},
bytopic: {value:"all"},
topic: {value:"topic",required:true},
topic: {value:"topic", required:true,
label:RED._("node-red:trigger.label.topic")},
outputs: {value:1}
},
inputs:1,

View File

@ -49,12 +49,16 @@
defaults: {
name: {value:""},
func: {value:"rbe"},
gap: {value:"",validate:RED.validators.regex(/^(\d*[.]*\d*|)(%|)$/)},
gap: {value:"",
label: RED._("node-red:rbe.label.gap"),
validate:RED.validators.regex(/^(\d*[.]*\d*|)(%|)$/)},
start: {value:""},
inout: {value:"out"},
septopics: {value:true},
property: {value:"payload",required:true},
topi: {value:"topic",required:true}
property: {value:"payload", required:true,
label:RED._("node-red:rbe.label.property")},
topi: {value:"topic", required:true,
label:RED._("node-red:rbe.label.topic")}
},
inputs:1,
outputs:1,

View File

@ -83,19 +83,25 @@
category: 'config',
defaults: {
name: {value:""},
cert: {value:"", validate: function(v) {
cert: {value:"", validate: function(v,opt) {
var currentKey = $("#node-config-input-key").val();
if (currentKey === undefined) {
currentKey = this.key;
}
return currentKey === '' || v != '';
if (currentKey === '' || v != '') {
return true;
}
return RED._("node-red:tls.error.invalid-cert");
}},
key: {value:"", validate: function(v) {
key: {value:"", validate: function(v,opt) {
var currentCert = $("#node-config-input-cert").val();
if (currentCert === undefined) {
currentCert = this.cert;
}
return currentCert === '' || v != '';
if (currentCert === '' || v != '') {
return true;
}
return RED._("node-red:tls.error.invalid-key");
}},
ca: {value:""},
certname: {value:""},

View File

@ -50,7 +50,16 @@
category: 'config',
defaults: {
name: {value:''},
url: {value:'',validate:function(v) { return (v && (v.indexOf('://') !== -1) && (v.trim().indexOf('http') === 0)); }},
url: {
value:'',
validate:function(v, opt) {
if ((v && (v.indexOf('://') !== -1) &&
(v.trim().indexOf('http') === 0))) {
return true;
}
return RED._("node-red:httpin.errors.invalid-url");
}
},
noproxy: {value:[]}
},
credentials: {

View File

@ -458,22 +458,34 @@
defaults: {
name: {value:""},
broker: {value:"",required:true},
port: {value:1883,required:false,validate:RED.validators.number(true)},
tls: {type:"tls-config",required: false},
clientid: {value:"", validate: function(v) {
port: {
value:1883,required:false,
label: RED._("node-red:mqtt.label.port"),
validate:RED.validators.number(true)},
tls: {type:"tls-config",required: false,
label:RED._("node-red:mqtt.label.use-tls") },
clientid: {value:"", validate: function(v, opt) {
var ok = false;
if ($("#node-config-input-clientid").length) {
// Currently editing the node
return $("#node-config-input-cleansession").is(":checked") || (v||"").length > 0;
ok = $("#node-config-input-cleansession").is(":checked") || (v||"").length > 0;
} else {
return (this.cleansession===undefined || this.cleansession) || (v||"").length > 0;
ok = (this.cleansession===undefined || this.cleansession) || (v||"").length > 0;
}
if (ok) {
return ok;
}
return RED._("node-red:mqtt.errors.invalid-client-id");
}},
autoConnect: {value: true},
usetls: {value: false},
verifyservercert: { value: false},
compatmode: { value: false},
protocolVersion: { value: 4},
keepalive: {value:60,validate:RED.validators.number()},
keepalive: {
value:60,
label: RED._("node-red:mqtt.label.keepalive"),
validate:RED.validators.number(false)},
cleansession: {value: true},
birthTopic: {value:""},
birthQos: {value:"0"},
@ -750,18 +762,21 @@
name: {value:""},
topic: {
value:"",
validate: function(v) {
validate: function(v, opt) {
var isDynamic = this.inputs === 1;
var topicTypeSelect = $("#node-input-topicType");
if (topicTypeSelect.length) {
isDynamic = topicTypeSelect.val()==='dynamic'
}
return isDynamic || ((!!v) && RED.validators.regex(/^(#$|(\+|[^+#]*)(\/(\+|[^+#]*))*(\/(\+|#|[^+#]*))?$)/)(v));
if (isDynamic || ((!!v) && RED.validators.regex(/^(#$|(\+|[^+#]*)(\/(\+|[^+#]*))*(\/(\+|#|[^+#]*))?$)/)(v))) {
return true;
}
return RED._("node-red:mqtt.errors.invalid-topic");
}
},
qos: {value: "2"},
datatype: {value:"auto-detect",required:true},
broker: {type:"mqtt-broker", required:true},
broker: {type:"mqtt-broker", required:true, label:RED._("node-red:mqtt.label.broker")},
// subscriptionIdentifier: {value:0},
nl: {value:false},
rap: {value:true},
@ -849,7 +864,8 @@
userProps: {value:''},
correl: {value:''},
expiry: {value:''},
broker: {type:"mqtt-broker", required:true}
broker: {type:"mqtt-broker", required:true,
label:RED._("node-red:mqtt.label.broker") }
},
color:"#d8bfd8",
inputs:1,

View File

@ -70,7 +70,8 @@
color:"rgb(231, 231, 174)",
defaults: {
name: {value:""},
url: {value:"",required:true},
url: {value:"", required:true,
label:RED._("node-red:httpin.label.url")},
method: {value:"get",required:true},
upload: {value:false},
swaggerDoc: {type:"swagger-doc", required:false}
@ -146,7 +147,10 @@
color:"rgb(231, 231, 174)",
defaults: {
name: {value:""},
statusCode: {value:"",validate: RED.validators.number(true)},
statusCode: {
value:"",
label: RED._("node-red:httpin.label.status"),
validate: RED.validators.number(true)},
headers: {value:{}}
},
inputs:1,

View File

@ -209,10 +209,22 @@
method:{value:"GET"},
ret: {value:"txt"},
paytoqs: {value: false},
url:{value:"",validate:function(v) { return (v.trim().length === 0) || (v.indexOf("://") === -1) || (v.trim().indexOf("http") === 0)} },
tls: {type:"tls-config",required: false},
url:{
value:"",
validate: function(v, opt) {
if ((v.trim().length === 0) ||
(v.indexOf("://") === -1) ||
(v.trim().indexOf("http") === 0)) {
return true;
}
return RED._("node-red:httpin.errors.invalid-url");
}
},
tls: {type:"tls-config",required: false,
label:RED._("node-red:httpin.tls-config") },
persist: {value:false},
proxy: {type:"http proxy",required: false},
proxy: {type:"http proxy",required: false,
label:RED._("node-red:httpin.proxy-config") },
authType: {value: ""},
senderr: {value: false},
headers: { value: [] }

View File

@ -83,13 +83,19 @@
return true;
}
else {
return RED.nodes.node(this.server) != null;
if (RED.nodes.node(this.server) != null) {
return true;
}
return RED._("node-red:websocket.errors.missing-server");
}
}
function ws_validateclient() {
if ($("#node-input-mode").val() === 'client' || (this.client && !this.server)) {
return RED.nodes.node(this.client) != null;
if (RED.nodes.node(this.client) != null) {
return true;
}
return RED._("node-red:websocket.errors.missing-client");
}
else {
return true;
@ -138,7 +144,9 @@
RED.nodes.registerType('websocket-listener',{
category: 'config',
defaults: {
path: {value:"",required:true,validate:RED.validators.regex(/^((?!\/debug\/ws).)*$/)},
path: {value:"",required:true,
label:RED._("node-red:websocket.label.path"),
validate:RED.validators.regex(/^((?!\/debug\/ws).)*$/)},
wholemsg: {value:"false"}
},
inputs:0,
@ -174,10 +182,16 @@
RED.nodes.registerType('websocket-client',{
category: 'config',
defaults: {
path: {value:"",required:true,validate:RED.validators.regex(/^((?!\/debug\/ws).)*$/)},
path: {
value:"",required:true,
label:RED._("node-red:websocket.label.path"),
validate:RED.validators.regex(/^((?!\/debug\/ws).)*$/)},
tls: {type:"tls-config",required: false},
wholemsg: {value:"false"},
hb: {value: "", validate: RED.validators.number(/*blank allowed*/true) },
hb: {
value: "",
label:RED._("node-red:websocket.sendheartbeat"),
validate: RED.validators.number(/*blank allowed*/true) },
subprotocol: {value:"",required: false}
},
inputs:0,

View File

@ -71,15 +71,27 @@
defaults: {
name: {value:""},
server: {value:"server", required:true},
host: {value:"", validate:function(v) { return (this.server == "server")||v.length > 0;} },
port: {value:"", required:true, validate:RED.validators.number()},
host: {
value:"",
validate:function(v, opt) {
if ((this.server == "server")||v.length > 0) {
return true;
}
return RED._("node-red:tcpin.errors.invalid-host");
}
},
port: {
value:"", required:true,
label:RED._("node-red:tcpin.label.port"),
validate:RED.validators.number(false)},
datamode:{value:"stream"},
datatype:{value:"buffer"},
newline:{value:""},
topic: {value:""},
trim: {value:false},
base64: {/*deprecated*/ value:false, required:true},
tls: {type:"tls-config", value:'', required:false}
tls: {type:"tls-config", value:'', required:false,
label:RED._("node-red:httpin.tls-config") }
},
inputs:0,
outputs:1,
@ -188,12 +200,29 @@
color: "Silver",
defaults: {
name: {value:""},
host: {value:"",validate:function(v) { return (this.beserver != "client")||v.length > 0;} },
port: {value:"",validate:function(v) { return (this.beserver == "reply")||RED.validators.number()(v); } },
host: {
value:"",
validate:function(v, opt) {
if ((this.beserver != "client")||v.length > 0) {
return true;
}
return RED._("node-red:tcpin.errors.invalid-host");
}
},
port: {
value:"",
validate:function(v) {
if ((this.beserver == "reply")||RED.validators.number()(v)) {
return true;
}
return RED._("node-red:tcpin.errors.invalid-port");
}
},
beserver: {value:"client", required:true},
base64: {value:false, required:true},
end: {value:false, required:true},
tls: {type:"tls-config", value:'', required:false}
tls: {type:"tls-config", value:'', required:false,
label:RED._("node-red:httpin.tls-config") }
},
inputs:1,
outputs:0,
@ -304,13 +333,17 @@
defaults: {
name: {value:""},
server: {value:""},
port: {value:"", validate:RED.validators.regex(/^(\d*|)$/)},
port: {
value:"",
label: RED._("node-red:tcpin.label.port"),
validate:RED.validators.regex(/^(\d*|)$/)
},
out: {value:"time", required:true},
ret: {value:"buffer"},
splitc: {value:"0", required:true},
newline: {value:""},
trim: {value:false},
tls: {type:"tls-config", value:'', required:false}
tls: {type:"tls-config", value:'', required:false, label:RED._("node-red:httpin.tls-config")}
},
inputs:1,
outputs:1,

View File

@ -62,10 +62,22 @@
defaults: {
name: {value:""},
iface: {value:""},
port: {value:"",required:true,validate:RED.validators.number()},
port: {
value:"", required:true,
label:RED._("node-red:udp.label.port"),
validate:RED.validators.number(false)
},
ipv: {value:"udp4"},
multicast: {value:"false"},
group: {value:"",validate:function(v) { return (this.multicast !== "true")||v.length > 0;} },
group: {
value:"",
validate:function(v,opt) {
if ((this.multicast !== "true")||v.length > 0) {
return true;
}
return RED._("node-red:udp.errors.invalid-group");
}
},
datatype: {value:"buffer",required:true}
},
inputs:0,

View File

@ -75,7 +75,10 @@
color:"#DEBD5C",
defaults: {
name: {value:""},
sep: {value:',',required:true,validate:RED.validators.regex(/^.{1,2}$/)},
sep: {
value:',', required:true,
label:RED._("node-red:csv.label.separator"),
validate:RED.validators.regex(/^.{1,2}$/)},
//quo: {value:'"',required:true},
hdrin: {value:""},
hdrout: {value:"none"},

View File

@ -31,7 +31,8 @@
color:"#DEBD5C",
defaults: {
name: {value:""},
property: {value:"payload",required:true},
property: {value:"payload",required:true,
label:RED._("node-red:json.label.property")},
action: {value:""},
pretty: {value:false}
},

View File

@ -26,7 +26,8 @@
color:"#DEBD5C",
defaults: {
name: {value:""},
property: {value:"payload",required:true},
property: {value:"payload",required:true,
label:RED._("node-red:common.label.property")},
attr: {value:""},
chr: {value:""}
},

View File

@ -15,7 +15,8 @@
category: 'parser',
color:"#DEBD5C",
defaults: {
property: {value:"payload",required:true},
property: {value:"payload",required:true,
label:RED._("node-red:common.label.property")},
name: {value:""}
},
inputs:1,

View File

@ -202,7 +202,11 @@
name: {value:""},
mode: {value:"auto"},
build: { value:"object"},
property: { value:"payload", validate:RED.validators.typedInput("propertyType")},
property: {
value:"payload",
label: RED._("node-red:join.message-prop"),
validate:RED.validators.typedInput("propertyType", false)
},
propertyType: { value:"msg"},
key: {value:"topic"},
joiner: { value:"\\n"},

View File

@ -73,9 +73,33 @@
defaults: {
name: {value:""},
mode: {value:"count"},
count: {value:10,validate:function(v) { return RED.validators.number(v) && (v >= 1); }},
overlap: {value:0,validate:function(v) { return RED.validators.number(v) && (v >= 0); }},
interval: {value:10,validate:function(v) { return RED.validators.number(v) && (v >= 1); }},
count: {
value:10,
validate:function(v, opt) {
if (RED.validators.number(v) && (v >= 1)) {
return true;
}
return RED._("node-red:batch.error.invalid-count");
}
},
overlap: {
value:0,
validate:function(v, opt) {
if (RED.validators.number(v) && (v >= 0)) {
return true;
}
return RED._("node-red:batch.error.invalid-overlap");
}
},
interval: {
value:10,
validate:function(v, opt) {
if (RED.validators.number(v) && (v >= 1)) {
return true;
}
return RED._("node-red:batch.error.invalid-interval");
}
},
allowEmptySequence: {value:false},
topics: {value:[{topic:""}]}
},

View File

@ -36,7 +36,8 @@
category: 'storage',
defaults: {
name: {value:""},
files: {value:"",required:true},
files: {value:"",required:true,
label:RED._("node-red:watch.label.files")},
recursive: {value:""}
},
color:"BurlyWood",

View File

@ -85,7 +85,11 @@
"errors": {
"failed": "inject failed, see log for details",
"toolong": "Interval too large",
"invalid-expr": "Invalid JSONata expression: __error__"
"invalid-expr": "Invalid JSONata expression: __error__",
"invalid-jsonata": "__prop__: invalid property expression: __error__",
"invalid-prop": "__prop__: invalid property expression: __error__",
"invalid-json": "__prop__: invalid JSON data: __error__",
"invalid-repeat": "Invalid repeat value"
}
},
"catch": {
@ -170,6 +174,7 @@
"outMode": "Mode",
"sendToAll": "Send to all connected link nodes",
"returnToCaller": "Return to calling link node",
"timeout": "timeout",
"linkCallType": "Link Type",
"staticLinkCall": "Fixed target",
"dynamicLinkCall": "Dynamic target (msg.target)",
@ -200,7 +205,9 @@
"alpnprotocol":"for use with ALPN"
},
"error": {
"missing-file": "No certificate/key file provided"
"missing-file": "No certificate/key file provided",
"invalid-cert": "Certificate not specified",
"invalid-key": "Private key not specified"
}
},
"exec": {
@ -255,7 +262,9 @@
"moduleNameError": "Invalid module variable name: __name__",
"moduleNameReserved": "Reserved variable name: __name__",
"inputListener":"Cannot add listener to 'input' event within Function",
"non-message-returned":"Function tried to send a message of type __type__"
"non-message-returned":"Function tried to send a message of type __type__",
"invalid-js": "Error in JavaScript code",
"missing-module": "Module __module__ missing"
}
},
"template": {
@ -309,6 +318,9 @@
"limit": "limit",
"limitTopic": "limit topic",
"random": "random",
"rate": "rate",
"random-first": "first random value",
"random-last": "last random value",
"units" : {
"second": {
"plural" : "Seconds",
@ -329,7 +341,12 @@
}
},
"errors": {
"too-many" : "too many pending messages in delay node"
"too-many" : "too many pending messages in delay node",
"invalid-timeout": "Invalid delay value",
"invalid-rate": "Invalid rate value",
"invalid-rate-unit": "Invalid rate unit value",
"invalid-random-first": "Invalid first random value",
"invalid-random-last": "Invalid last random value"
}
},
"trigger": {
@ -366,7 +383,9 @@
"reset": "Reset the trigger if:",
"resetMessage":"msg.reset is set",
"resetPayload":"msg.payload equals",
"resetprompt": "optional"
"resetprompt": "optional",
"duration": "duration",
"topic": "topic"
}
},
"comment": {
@ -471,7 +490,9 @@
"invalid-json-parse": "Failed to parse JSON string",
"invalid-action-action": "Invalid action specified",
"invalid-action-alreadyconnected": "Disconnect from broker before connecting",
"invalid-action-badsubscription": "msg.topic is missing or invalid"
"invalid-action-badsubscription": "msg.topic is missing or invalid",
"invalid-client-id": "Missing Client ID"
}
},
"httpin": {
@ -527,7 +548,8 @@
"invalid-transport":"non-http transport requested",
"timeout-isnan": "Timeout value is not a valid number, ignoring",
"timeout-isnegative": "Timeout value is negative, ignoring",
"invalid-payload": "Invalid payload"
"invalid-payload": "Invalid payload",
"invalid-url": "Invalid url"
},
"status": {
"requesting": "requesting"
@ -560,7 +582,9 @@
"connect-error": "An error occurred on the ws connection: ",
"send-error": "An error occurred while sending: ",
"missing-conf": "Missing server configuration",
"duplicate-path": "Cannot have two WebSocket listeners on the same path: __path__"
"duplicate-path": "Cannot have two WebSocket listeners on the same path: __path__",
"missing-server": "Missing server configuration",
"missing-client": "Missing client configuration"
}
},
"watch": {
@ -631,7 +655,9 @@
"no-host": "Host and/or port not set",
"connect-timeout": "connect timeout",
"connect-fail": "connect failed",
"bad-string": "failed to convert to string"
"bad-string": "failed to convert to string",
"invalid-host": "Invalid host",
"invalid-port": "Invalid port"
}
},
"udp": {
@ -645,7 +671,8 @@
"send": "Send a",
"toport": "to port",
"address": "Address",
"decode-base64": "Decode Base64 encoded payload?"
"decode-base64": "Decode Base64 encoded payload?",
"port": "port"
},
"placeholder": {
"interface": "(optional) local interface or address to bind to",
@ -692,7 +719,8 @@
"port-notset": "udp: port not set",
"port-invalid": "udp: port number not valid",
"alreadyused": "udp: port __port__ already in use",
"ifnotfound": "udp: interface __iface__ not found"
"ifnotfound": "udp: interface __iface__ not found",
"invalid-group": "invalid multicast group"
}
},
"switch": {
@ -756,7 +784,9 @@
"invalid-from": "Invalid 'from' property: __error__",
"invalid-json": "Invalid 'to' JSON property",
"invalid-expr": "Invalid JSONata expression: __error__",
"no-override": "Cannot set property of non-object type: __property__"
"no-override": "Cannot set property of non-object type: __property__",
"invalid-prop": "Invalid property expression: __property__",
"invalid-json-data": "Invalid JSON data: __error__"
}
},
"range": {
@ -767,7 +797,11 @@
"resultrange": "to the target range",
"from": "from",
"to": "to",
"roundresult": "Round result to the nearest integer?"
"roundresult": "Round result to the nearest integer?",
"minin": "input from",
"maxin": "input to",
"minout": "target from",
"maxout": "target to"
},
"placeholder": {
"min": "e.g. 0",
@ -992,6 +1026,7 @@
"complete": "After a message with the <code>msg.complete</code> property set",
"tip": "This mode assumes this node is either paired with a <i>split</i> node or the received messages will have a properly configured <code>msg.parts</code> property.",
"too-many": "too many pending messages in join node",
"message-prop": "message property",
"merge": {
"topics-label": "Merged Topics",
"topics": "topics",
@ -1049,7 +1084,12 @@
},
"too-many" : "too many pending messages in batch node",
"unexpected" : "unexpected mode",
"no-parts" : "no parts property in message"
"no-parts" : "no parts property in message",
"error": {
"invalid-count": "Invalid count",
"invalid-overlap": "Invalid overlap",
"invalid-interval": "Invalid interval"
}
},
"rbe": {
"rbe": "filter",
@ -1058,7 +1098,10 @@
"init": "Send initial value",
"start": "Start value",
"name": "Name",
"septopics": "Apply mode separately for each "
"septopics": "Apply mode separately for each ",
"gap": "value change",
"property": "property",
"topic": "topic"
},
"placeholder":{
"bandgap": "e.g. 10 or 5%",

View File

@ -85,7 +85,11 @@
"errors": {
"failed": "inject処理が失敗しました。詳細はログを確認してください。",
"toolong": "時間間隔が大き過ぎます",
"invalid-expr": "JSONata式が不正: __error__"
"invalid-expr": "JSONata式が不正: __error__",
"invalid-jsonata": "__prop__: プロパティ式が不正: __error__",
"invalid-prop": "__prop__: プロパティ式が不正: __error__",
"invalid-json": "__prop__: JSONデータが不正: __error__",
"invalid-repeat": "繰り返し数が不正"
}
},
"catch": {
@ -170,6 +174,7 @@
"outMode": "モード",
"sendToAll": "接続された全てのlinkードへ送信",
"returnToCaller": "link callードへ返却",
"timeout": "タイムアウト",
"linkCallType": "リンクの種類",
"staticLinkCall": "対象を固定で指定",
"dynamicLinkCall": "対象を動的に指定 (msg.target)",
@ -200,7 +205,9 @@
"alpnprotocol": "ALPNで使用"
},
"error": {
"missing-file": "証明書と秘密鍵のファイルが設定されていません"
"missing-file": "証明書と秘密鍵のファイルが設定されていません",
"invalid-cert": "証明書が指定されていません",
"invalid-key": "秘密鍵が指定されていません"
}
},
"exec": {
@ -255,7 +262,9 @@
"moduleNameError": "モジュール変数名が不正です: __name__",
"moduleNameReserved": "予約された変数名です: __name__",
"inputListener": "コード内で'input'イベントのリスナを設定できません",
"non-message-returned": "Functionードが __type__ 型のメッセージ送信を試みました"
"non-message-returned": "Functionードが __type__ 型のメッセージ送信を試みました",
"invalid-js": "JavaScriptコードのエラー",
"missing-module": "モジュール __module__ が存在しません"
}
},
"template": {
@ -309,6 +318,9 @@
"limit": "limit",
"limitTopic": "limit topic",
"random": "random",
"rate": "流量",
"random-first": "ランダム最小値",
"random-last": "ランダム最大値",
"units": {
"second": {
"plural": "秒",
@ -329,7 +341,12 @@
}
},
"errors": {
"too-many": "delayード内で保持しているメッセージが多すぎます"
"too-many": "delayード内で保持しているメッセージが多すぎます",
"invalid-timeout": "遅延時間が不正",
"invalid-rate": "流量値が不正",
"invalid-rate-unit": "流量単位時間が不正",
"invalid-random-first": "ランダム最小値が不正",
"invalid-random-last": "ランダム最大値が不正"
}
},
"trigger": {
@ -366,7 +383,9 @@
"reset": "初期化条件:",
"resetMessage": "msg.resetを設定",
"resetPayload": "msg.payloadが次の値",
"resetprompt": "任意"
"resetprompt": "任意",
"duration": "時間間隔",
"topic": "トピック"
}
},
"comment": {
@ -470,7 +489,8 @@
"invalid-json-parse": "JSON文字列のパースに失敗しました",
"invalid-action-action": "指定された動作が不正です",
"invalid-action-alreadyconnected": "接続する前にブローカから切断してください",
"invalid-action-badsubscription": "msg.topicが存在しないか不正です"
"invalid-action-badsubscription": "msg.topicが存在しないか不正です",
"invalid-client-id": "クライアントIDが未指定"
}
},
"httpin": {
@ -526,7 +546,8 @@
"invalid-transport": "httpでないトランスポートが要求されました",
"timeout-isnan": "タイムアウト値が数値ではないため無視します",
"timeout-isnegative": "タイムアウト値が負数のため無視します",
"invalid-payload": "不正なペイロード"
"invalid-payload": "不正なペイロード",
"invalid-url": "URLが不正"
},
"status": {
"requesting": "要求中"
@ -559,7 +580,9 @@
"connect-error": "ws接続でエラーが発生しました: ",
"send-error": "送信中にエラーが発生しました: ",
"missing-conf": "サーバ設定が不足しています",
"duplicate-path": "同じパスに対して2つのWebSocketリスナは指定できません: __path__"
"duplicate-path": "同じパスに対して2つのWebSocketリスナは指定できません: __path__",
"missing-server": "サーバが設定されていません",
"missing-client": "クライアントが設定されていません"
}
},
"watch": {
@ -628,7 +651,9 @@
"no-host": "ホスト名またはポートが設定されていません",
"connect-timeout": "接続がタイムアウトしました",
"connect-fail": "接続に失敗しました",
"bad-string": "文字列への変換に失敗しました"
"bad-string": "文字列への変換に失敗しました",
"invalid-host": "ホスト名が不正",
"invalid-port": "ポートが不正"
}
},
"udp": {
@ -642,7 +667,8 @@
"send": "送信",
"toport": "ポート",
"address": "アドレス",
"decode-base64": "Base64形式のペイロードを復号"
"decode-base64": "Base64形式のペイロードを復号",
"port": "ポート"
},
"placeholder": {
"interface": "(任意) 使用するローカルインターフェイスもしくはアドレス",
@ -689,7 +715,8 @@
"port-notset": "udp: ポートが設定されていません",
"port-invalid": "udp: ポート番号が不正です",
"alreadyused": "udp: 既に__port__番ポートが使用されています",
"ifnotfound": "udp: インターフェイス __iface__ がありません"
"ifnotfound": "udp: インターフェイス __iface__ がありません",
"invalid-group": "マルチキャストグループが不正"
}
},
"switch": {
@ -753,7 +780,9 @@
"invalid-from": "操作対象のプロパティが不正: __error__",
"invalid-json": "対象の値のJSONプロパティが不正",
"invalid-expr": "JSONata式が不正: __error__",
"no-override": "オブジェクト型でないプロパティを設定できません: __property__"
"no-override": "オブジェクト型でないプロパティを設定できません: __property__",
"invalid-prop": "プロパティ式が不正: __property__",
"invalid-json-data": "JSONデータが不正: __error__"
}
},
"range": {
@ -764,7 +793,11 @@
"resultrange": "出力値の範囲",
"from": "最小値",
"to": "最大値",
"roundresult": "小数値を四捨五入し整数値へ変換"
"roundresult": "小数値を四捨五入し整数値へ変換",
"minin": "入力最小値",
"maxin": "入力最大値",
"minout": "出力最小値",
"maxout": "出力最大値"
},
"placeholder": {
"min": "例) 0",
@ -989,7 +1022,8 @@
"complete": "<code>msg.complete</code> プロパティが設定されたメッセージ受信後",
"tip": "このモードでは、本ノードが <i>split</i> ノードと組となるか、 <code>msg.parts</code> プロパティが設定されたメッセージを受け取ることが前提となります。",
"too-many": "joinード内部で保持しているメッセージが多すぎます",
"merge": {
"message-prop": "メッセージプロパティ",
"merge": {
"topics-label": "対象トピック",
"topics": "トピック",
"topic": "トピック",
@ -1046,7 +1080,12 @@
},
"too-many": "batchード内で保持しているメッセージが多すぎます",
"unexpected": "想定外のモード",
"no-parts": "メッセージにpartsプロパティがありません"
"no-parts": "メッセージにpartsプロパティがありません",
"error": {
"invalid-count": "メッセージ数が不正",
"invalid-overlap": "オーバラップが不正",
"invalid-interval": "時間間隔が不正"
}
},
"rbe": {
"rbe": "filter",
@ -1055,7 +1094,10 @@
"init": "初期値を送付",
"start": "初期値",
"name": "名前",
"septopics": "個別に動作を適用"
"septopics": "個別に動作を適用",
"gap": "変化量",
"property": "プロパティ",
"topic": "トピック"
},
"placeholder": {
"bandgap": "例:10、5%",