open-policy-agentrego

OPA giving error "rego_parse_error: var cannot be used for rule name"


I have a simple rego file like this:

package example

default isApplicable := false

isApplicable if {
   timeNow := time.now_ns()
   timeNow >= input.startDatetime
}

and I keep getting parse error:

rego_parse_error: var cannot be used for rule name

Solution

  • I found out that I had to have import future.keywords.if in my rego. After adding it the error is gone.