What alternatives exist to deprecated any() and all() functions? #108
Unanswered
anderseknert
asked this question in
OPA and Rego
Replies: 1 comment 1 reply
-
@anderseknert might be time to update this to show the |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
OPA used to include functions called
any
andall
, but these have been deprecated for a long time. Since people sometimes see these in older versions of the docs and wonder what they were doing, or why they were deprecated, here's an explanation.any
output := any(array)
output would betrue
if any of the elements inarray
was equal totrue
This is trival to do by other means. Simply use the
in
operator to check for presence oftrue
in an array.Using
in
of course has the benefit that it can check for any type of value, not justtrue
.all
output := all(array)
output would betrue
if all of the elements inarray
was equal totrue
. This can easily be checked usingevery
If you want to replace the deprecated functions with your own implementations, you could use something like the below:
Beta Was this translation helpful? Give feedback.
All reactions