Logical Operators

This section describes the following logical operators.

switch
logic_and
logic_or
logic-not

switch

switch(<conditional>, <a>, <b>)

switch operates much like an if statement. It accepts a conditional as the first argument and will return a if true, b if false. Any argument passed in the first argument will be converted to a boolean using to_b. switch may appear when defining datasource fields or in validations.

Examples:

switch(lt("a","b"), "first", "second") # returns "first" as the condition is true 

switch(0, "a", "b") # returns "b" as 0 evaluates to false 

switch("", "a", "b") # returns "b" as empty string evaluates to false 

logic_and

logic_and(<conditional>, <conditional>)

logic_and returns true if both arguments evaluate to true. Anything passed as the first or second argument will be converted to a boolean using to_b. logic_and may appear when defining datasource fields or in validations.

Examples:

logic_and("first", "second") # true as both are non-empty 

logic_and(true, true) # returns true 

logic_or

logic_or(<conditional>, <conditional>)

logic_or returns true if either argument evaluates to true. Anything passed as the first or second argument will be converted to a boolean using to_b. logic_or may appear when defining datasource fields or in validations.

Examples:

logic_or("first", "") # true as first element is non-empty 

logic_or(true, false) # returns true 

logic-not

logic_not(<conditional>)

logic_not returns true if the conditional evaluates to false. Anything passed as the first or second argument will be converted to a boolean using to_d. logic_not may appear when defining datasource fields or in validations.

Examples:

logic_not("") # true as first element evaluates to false 

logic_not(false) # true