Skip to main content

Context Operators

Context Operators

OperatorsInstruction
valval
existsexists
varvar
missingmissing
missing_somemissing_some

These operators allow you to fetch data from the context & check for the existence of values.

val

The val operator is used to fetch data from the context, and is the preferred method of fetching data in JSON Logic Core.

This operator receives the path to the data you wish to fetch, and returns the value.

If you wish, you can descend into objects and arrays:

exists

This operator is used to check if a value exists in the context.

var

⚠️ This operator has been deprecated. It will continue to work, but is considered a legacy operator. Consider: val

By just using '' as the input for var, you can get the current value that is in scope, regardless of its type.

Additionally, these operators support handlebars style data traversal inside of higher order operators.

If you wish, you can drill down and fetch specific properties:

Missing

⚠️ This operator has been deprecated. It will continue to work, but is considered a legacy operator. Consider: exists

Returns an array of the values that are "missing"

Missing Some

⚠️ This operator has been deprecated. It will continue to work, but is considered a legacy operator. Consider: exists

From json-logic-js, passing in the number of required variables & the variable names, if it has enough of them, it'll return an empty array, otherwise it'll return the items that are missing.