Skip to main content


Summary: Use the if keyword

Category: Idiomatic


package policy


is_admin {
"admin" in input.user.roles


package policy

import future.keywords.if

is_admin if {
"admin" in input.user.roles

# alternatively

is_admin if "admin" in input.user.roles


The if keyword helps communicate what Rego rules really are — conditional assignments. Using if in other words makes the rule read the same way in English as it will be interpreted by OPA, i.e:

rule := "some value" if some_condition

OPA version 1.0, which is planned for 2024, will make the if keyword mandatory. This rule helps you get ahead of the curve and start using it today.

Note: don't forget to import future.keywords.if! Or from OPA v0.59.0 and onwards, import rego.v1.

Tip: When either of the imports mentioned above are found in a Rego file, the if keyword will be inserted automatically at any applicable location by the opa fmt tool.

Configuration Options

This linter rule provides the following configuration options:

# one of "error", "warning", "ignore"
level: error


If you think you've found a problem with this rule or its documentation, would like to suggest improvements, new rules, or just talk about Regal in general, please join us in the #regal channel in the Styra Community Slack!