Skip to main content

Boolean functions

$boolean()

Signature: $boolean(arg)

Casts the argument to a Boolean using the following rules:

Argument typeResult
Booleanunchanged
string: emptyfalse
string: non-emptytrue
number: 0false
number: non-zerotrue
nullfalse
array: emptyfalse
array: contains a member that casts to truetrue
array: all members cast to falsefalse
object: emptyfalse
object: non-emptytrue
functionfalse

$not()

Signature: $not(arg)

Returns Boolean NOT on the argument. arg is first cast to a boolean

$exists()

Signature: $exists(arg)

Returns Boolean true if the arg expression evaluates to a value, or false if the expression does not match anything (e.g. a path to a non-existent field reference).