mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
parent
4fe7ea00b0
commit
3a97e20bde
@ -1,5 +1,5 @@
|
||||
<!--
|
||||
Copyright 2013,2015 IBM Corp.
|
||||
Copyright 2013, 2016 IBM Corp.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
@ -37,7 +37,7 @@
|
||||
category: 'input',
|
||||
defaults: {
|
||||
name: {value:""},
|
||||
topic: {value:"",required:true},
|
||||
topic: {value:"",required:true,validate: RED.validators.regex(/^(#$|(\+|[^+#]*)(\/(\+|[^+#]*))*(\/(\+|#|[^+#]*))?$)/)},
|
||||
broker: {type:"mqtt-broker", required:true}
|
||||
},
|
||||
color:"#d8bfd8",
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright 2013,2015 IBM Corp.
|
||||
* Copyright 2013, 2016 IBM Corp.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -306,6 +306,9 @@ module.exports = function(RED) {
|
||||
this.topic = n.topic;
|
||||
this.broker = n.broker;
|
||||
this.brokerConn = RED.nodes.getNode(this.broker);
|
||||
if (!/^(#$|(\+|[^+#]*)(\/(\+|[^+#]*))*(\/(\+|#|[^+#]*))?$)/.test(this.topic)) {
|
||||
return this.warn(RED._("mqtt.errors.invalid-topic"));
|
||||
}
|
||||
var node = this;
|
||||
if (this.brokerConn) {
|
||||
this.status({fill:"red",shape:"ring",text:"common.status.disconnected"});
|
||||
|
Loading…
Reference in New Issue
Block a user