-
Notifications
You must be signed in to change notification settings - Fork 6
AND
AND
returns true if the provided arguments all return logical true, otherwise it returns false. Everything except FALSE is treated as true.
AND(arg1, [arg2...])
-
arg1
is an expression that can be interpreted as true or false (including numbers, strings, and arrays etc.) -
arg2
is optional, and has the same restrictions asarg1
-
AND
can take an arbitrary number of additional arguments as well
Let's say we're given a response with some fleet deployment information that looks like this:
{
"company_a":{
"deployments":{
"fleet_1":true,
"fleet_2":true,
"fleet_3":true
}
}
}
And another set of deployment information from an api that returns 1 as true, and where there was no data returned for the fleet_2
element:
{
"company_b":{
"deployments":{
"fleet_1":1,
"fleet_2":null
}
}
}
If we want to determine that all deployments are completed, we can use AND
:
AND(company_a.deployments.fleet_1, company_a.deployments.fleet_2, company_a.deployments.fleet_3)
This will return true
.
We can also interpolate different kinds of "truthy" results.
AND(company_a.deployments.fleet_1, company_b.deployments.fleet_1) => true
AND(company_a.deployments.fleet_1, company_b.deployments.fleet_2) => false