Design requirements for nodes and their connection types

Are there design requirements (some metadata) that describe the kinds of input and output connections that the node supports?

For example, how do I specify that node input must be a number? or RTSP?

More specifically, is there a way to inspect a node and then disallow certain (nonsensical) linkings?

Have a look in the docs for input validation.

As far as I'm aware, no. Node-RED tends to rely on conventions.

1 Like

Just to clarify, that only covers validate the properties of a node - which I don't believe is what is being asked here.

Node-RED doesn't have any concept of typing on the inputs/outputs. It has been discussed from time to time, but nothing conclusive has come from that.

1 Like

Argh ... just deleted my reply.

Thanks!

Yes, I am looking for something akin what IDE/compiler does when it checks function declarations against function calls - and throws errors/warning for mismatches.

Building on that, I would also like to implement next level - one that could warn developer that, e.g., MQTT broker has multiple publishers for a topic but no subscribers (or vice versa).

This said, I will find and read input validation docs.

How can you tell that when an instance of node-red only knows about actions on one of the clients connected to the broker? For example, if you have a sensor publishing its values to MQTT then node red will be subscribed to that topic but will not publish to it.

Good question.

First, this was meant as aspirational - beyond simple syntax and type checking - and MQTT was one example that came to mind.

I was assuming cases where both publishers and subscribers are within node-red. (Arguably, a bad assumption.) In any case, my MQTTInNode and MQTTOutNode instances would have "Topic" values (and mqtt-broker "Server" values) - and these could be inspected. Maybe all this does is surface typos on topic names.

My larger focus is on providing high (though configurable) guardrails to help "accidental coders" be more successful, more productive.

You may also want to have a look at nrlint - a linter for flows - GitHub - node-red/nrlint: Node-RED Flow Linter

It lets you create custom rules that could be used to apply additional checks to the flows.

1 Like