Prism · Predicates

$empty

True for null, an empty string, an empty list and an empty object. Everything else is not empty, 0 and false included.

The source
{ nothing: null, text: '', list: [], zero: 0 }
The config
{
  nothing: { $empty: { $ref: '$.nothing' } },
  text: { $empty: { $ref: '$.text' } },
  list: { $empty: { $ref: '$.list' } },
  zero: { $empty: { $ref: '$.zero' } },
}
What comes out
{ nothing: true, text: true, list: true, zero: false }
Output matches the expected value

Runs in this page on the installed package. The input and the expected output are defined by the example.