1
0
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:
Stephen McLaughlin 2022-05-02 21:28:04 +01:00 committed by GitHub
parent be3b5b7fe2
commit 9b644e3c47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -457,11 +457,11 @@
* @param {string} topic
* @returns `true` if it is a valid topic
*/
function validateMQTTPublishTopic(topic) {
if(!topic || topic == "") {
function validateMQTTPublishTopic(topic, opts) {
if(!topic || topic == "" || !/[\+#\b\f\n\r\t\v\0]/.test(topic)) {
return true;
}
return !/[\+#\b\f\n\r\t\v\0]/.test(topic);
return RED._("node-red:mqtt.errors.invalid-topic");
}
RED.nodes.registerType('mqtt-broker',{
category: 'config',