Skip to main content
Version: v1.17.0

assert

Operator

assert evaluate an assertion

Synopsis

assert <expr>

Description

The assert operator evaluates the Boolean expression <expr> for each input value, yielding its input value if <expr> evaluates to true or a structured error if it does not.

Examples

echo {a:1} | zq -z 'assert a > 0' -

=>

{a:1}
echo {a:-1} | zq -z 'assert a > 0' -

=>

error({message:"assertion failed",expr:"a > 0",on:{a:-1}})