Predicates

Introduction

Predicates are boolean JavaScript expressions that must return either true or false.

Predicates are primary used for controlling execution and for filtering and are always evaluated during runtime.

Context data that can be used in the expression are available in scopes, defined by the current context. Scopes follow the same structure as for expansion, but using JavaScript types.

Syntax

A predicate MUST:

  • be a string ("...")

  • be valid JavaScript (ECMAScript 2023)

  • evaluate to a boolean value (true/false) or a function that returns a boolean value

// Simple predicate that is always true
{
    "predicate": "true",
}

Since predicates are JavaScript all features of JavaScript are supported including, but not limited to:

  • operators (==, !=, >, >=, <, <=)

  • strict operators (===, !==)

  • array indexing using bracket notation (arr[3])

  • property access using bracket notation (obj['property-name'])

For more information about JavaScript, see: https://developer.mozilla.org/en-US/docs/Web/JavaScript

Extensions

Extensions are libraries containing useful functions when working with predicates. For more information, see: Extensions

Scopes

Scopes are the named top level objects containing context data (for example request or session). Available scopes depends on the context.

Data in scopes are accessed different depending on the type of objects included in the path, but adheres to the rules of JavaScript.

Last updated