How to check if an array is empty in OPA Rego

4.1k Views Asked by At

I have an array which declare like this- arr = []. I want to check it it's empty. I tried: count(arr)==0, is_null(arr), arr==[] and arr=="".

1

There are 1 best solutions below

0
On

Using count would be the the idiomatic way:

arr_is_empty {
    count(arr) == 0
}