mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Use new validation option to return better label
Co-authored-by: Nick O'Leary <nick.oleary@gmail.com>
This commit is contained in:
parent
a2de514c05
commit
ca204dea2d
@ -442,7 +442,17 @@
|
|||||||
}
|
}
|
||||||
return defaultContentType || 'none'
|
return defaultContentType || 'none'
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Test a topic string is valid for publishing
|
||||||
|
* @param {string} topic
|
||||||
|
* @returns `true` if it is a valid topic
|
||||||
|
*/
|
||||||
|
function validateMQTTPublishTopic(topic, opts) {
|
||||||
|
if(!topic || topic == "" || !/[\+#\b\f\n\r\t\v\0]/.test(topic)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return RED._("node-red:mqtt.errors.invalid-topic");
|
||||||
|
}
|
||||||
RED.nodes.registerType('mqtt-broker',{
|
RED.nodes.registerType('mqtt-broker',{
|
||||||
category: 'config',
|
category: 'config',
|
||||||
defaults: {
|
defaults: {
|
||||||
|
Loading…
Reference in New Issue
Block a user