Skip to main content

Bool Node

Bool Node Screenshot

Overview

The Bool Node is used to output a boolean constant or convert an input value into a boolean. This node can be useful when you need to create a boolean value for use in other nodes, such as the If Node or If/Else Node.

The Bool Node can either output a constant boolean value that you set in the node's settings, or it can take an input and convert it into a boolean. The conversion follows JavaScript's rules for truthy and falsy values, with two exception:

  • Empty arrays are considered falsey
  • The string "false" is considered falsey.

If you need to treat empty arrays as truthy, or the string "false" as truthy, you can use the Code Node

Inputs

TitleData TypeDescriptionDefault ValueNotes
InputanyThe value to be converted to a boolean. This input is only available if Use Input is enabled.N/A

Example 1: Using a Constant Boolean Value

  1. Add a Bool Node to your graph.
  2. Set the Value setting to true.
  3. Run the graph. The Value output of the Bool Node will be true.

Example 2: Converting an Input to a Boolean

  1. Add a Bool Node to your graph.
  2. Enable the Use Input setting.
  3. Add a Text Node to your graph and set the text to "Hello".
  4. Connect the output of the Text Node to the Input of the Bool Node.
  5. Run the graph. The Value output of the Bool Node will be true, because the string "Hello" is a truthy value in JavaScript.

Error Handling

The Bool Node cannot error under normal circumstances. If the Use Input setting is enabled and no input is connected, the node will output false.

FAQ

Q: What values are considered truthy and falsy in JavaScript?

A: The following values are considered falsy:

  • false
  • 0
  • '' (empty string)
  • null
  • undefined
  • NaN
  • In Rivet, empty arrays are also considered falsy.
  • In Rivet, the string "false" is also considered falsy.

All other values are considered truthy.

Q: Can I use the Bool Node to check if an array is empty?

A: Yes, if you connect an array to the Input of a Bool Node, the Value output will be false if the array is empty. If the array is not empty, the Value output will be true.

Q: Can I use the Bool Node to check if a string is empty?

A: Yes, you can connect a Text Node to the Input of a Bool Node. If the string is empty, the Value output of the Bool Node will be false. If the string is not empty, the Value output will be true.

Q: Can I use the Bool Node to check if a number is zero?

A: Yes, you can connect a Number Node to the Input of a Bool Node. If the number is zero, the Value output of the Bool Node will be false. If the number is not zero, the Value output will be true.

See Also