Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-red-contrib-assert

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-red-contrib-assert

A node-red node to check message property values.

  • 1.3.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
20
decreased by-13.04%
Maintainers
1
Weekly downloads
 
Created
Source

node-red-contrib-assert

A Node Red node for asserting message properties within a flow.

This node will check all of the specified properties in a message or in the global or flow contexts to confirm that they meet the required format.

The assert node is configured with a list of rules. Each rule tests one specific property using either the usual comparison operators, ranges, regex, null, not null, boolean values, or type. Comparisons can be made against static values, other properties, and the property's previous value. The specification of the property to be checked is quite powerful, allowing the probing inside objects and arrays using Javascript descriptors.

For a message to pass through the assert node, all tests must pass. The first failing test is reported as an error which can be caught and processed out of band. Failed messages are dropped from the flow.

How to Use

Just insert the Assert node in your flow. Set the appropriate test conditions to check that the specified properties are valid when a message passes through the Assert node. Note that you can test global and flow properties as well. Any message that does not pass the tests will be dropped and an error reported.

The 'is within' test condition has an option to use the mean value of a sliding window of previous values. When you select 'mean', enter in the size of the window you would like to use.

Here is a sample flow that checks the msg.payload property value is less than 100:

Sample Flow

[{"id":"ede6fe04.eded3","type":"assert","z":"8b42e25d.61776","name":"Payload < 100",
"rules":[{"property":"payload","propertyType":"msg","type":"lt","value":"100","valueType":"num"}],
"x":442.5,"y":442,"wires":[["4fd55a87.740b74"]]},
{"id":"4fd55a87.740b74","type":"debug","z":"8b42e25d.61776","name":"","active":true,"console":"false",
"complete":"false","x":670.5,"y":445,"wires":[]},{"id":"5f32bb08.e7a17c","type":"inject","z":"8b42e25d.61776",
"name":"","topic":"","payload":"50","payloadType":"num","repeat":"","crontab":"","once":false,"x":172.5,
"y":440,"wires":[["ede6fe04.eded3"]]},{"id":"cb3d81c3.e0ecb8","type":"inject","z":"8b42e25d.61776","name":"","topic":"",
"payload":"150","payloadType":"num","repeat":"","crontab":"","once":false,"x":140.5,"y":513,
"wires":[["ede6fe04.eded3"]]},{"id":"ef019fc4.e98a2","type":"catch","z":"8b42e25d.61776",
"name":"Assert failed","scope":["ede6fe04.eded3"],"x":448.5,"y":522,"wires":[["ff38f898.9fb15"]]},
{"id":"ff38f898.9fb15","type":"debug","z":"8b42e25d.61776","name":"","active":true,"console":"false",
"complete":"error.message","x":697.5,"y":519,"wires":[]}]

Keywords

FAQs

Package last updated on 31 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc