# Rule

This example rule returns a `msg` when a resource has been marked for deletion and more than 10 minutes have passed since the deletion timestamp.

```rego
# The first line MUST be package name, because the engine reads the first line as package name.
# Package names in the same directory MUST be same.
package infra

# The rule name MUST be `violation`, because the Engine evals a rule and query the results by `violation`.
violation[msg] {
    # If the `deletionTimestamp` exists, continue to eval. 
    input.metadata.deletionTimestamp

    # Define a var
	time_difference := time.now_ns() - time.parse_rfc3339_ns(input.metadata.deletionTimestamp)

    # If the result is `true`, continue to eval.
    time_difference > 600000000000

    # Return the result `msg`.
    msg := {
        "name": "DeletingResource",
        "level": "warning",
        "message": sprintf("resource is deleted at %v and more than 10min", [input.metadata.deletionTimestamp]),
    }
}
```

Once you've finished your rule, test it out on the [Rego Playground](https://play.openpolicyagent.org/) to make sure it's correct.

For more information about the language, please see the official [Open Policy Agent policy language documentation](https://www.openpolicyagent.org/docs/latest/policy-language/).
