Skip to main content

$nand

The $nand operator evaluates multiple expressions and returns false if all of them are truthy, otherwise it returns true. It’s the negation of the $and operator.

Input

  • An array of expressions to evaluate
  • Each expression is evaluated in order from left to right

Output

  • false if all expressions evaluate to truthy values
  • true if any expression evaluates to a falsy value

Examples

All Truthy Values

{
  "$nand": [
    true,
    true,
    true
  ]
}
Result: false

With Falsy Value

{
  "$nand": [
    true,
    false,
    true
  ]
}
Result: true

Multiple Expressions

[
  {
    "$nand": [
      {
        "$gte": [
          {
            "$input": "age"
          },
          18
        ]
      },
      {
        "$eq": [
          {
            "$input": "status"
          },
          "active"
        ]
      }
    ]
  }
]
Result: false if the age is greater than or equal to 18 AND the status is “active”, otherwise true