Boolean | BOOLEAN
Syntax
BOOLEAN( [input], [default = false] )
Parameters
input
Any data may be used as the input.
default
The default value if INPUT cannot be converted to a BOOLEAN value.
If the default value is used, it will be converted to a BOOLEAN value before being returned.
The default value will only be used if VALUE is UNDEFINED or NULL.
Return Value
VALUE is converted to a BOOLEAN value and returned.Description
Converts a value to either TRUE or FALSE. The following rules are used when doing the conversion:- TRUE and FALSE are returned as is
- The TEXT values "true", "TRUE", "True" and "1" are returned as TRUE
- The TEXT values "false", "FALSE", "False", "0", and "" are returned as FALSE
- The value 0 is returned as FALSE
- The values NULL and UNDEFINED are converted to the provided DEFAULT
- All other values are returned as TRUE
Examples
BOOLEAN(true) # returns TRUEBOOLEAN(false) # returns FALSEBOOLEAN(null) # returns FALSEBOOLEAN(undefined) # returns FALSEBOOLEAN(null, true) # returns TRUEBOOLEAN(undefined, true) # returns TRUEBOOLEAN(null, 1) # returns TRUEBOOLEAN(1) # returns TRUEBOOLEAN(0) # returns FALSEBOOLEAN("FALSE") # returns FALSEBOOLEAN("TRUE") # returns TRUEBOOLEAN([]) # returns TRUEBOOLEAN(MAP()) # returns TRUE