Kfir-G
Kfir-G

Reputation: 21

How to check if an array is empty in OPA Rego

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=="".

Upvotes: 2

Views: 5659

Answers (1)

Devoops
Devoops

Reputation: 2360

Using count would be the the idiomatic way:

arr_is_empty {
    count(arr) == 0
}

Upvotes: 4

Related Questions