Validate PolicyDomain YAML files for syntax errors and lint embedded Rego code.
mpe lint --file <file> [--opa-flags <flags>] [--no-opa-flags] [--regal]
The lint command performs comprehensive validation of PolicyDomain YAML files. It operates in two modes:
Runs the full validation pipeline:
opa check for additional linting--regal)Runs Regal linting instead of the standard validation pipeline. Regal is OPA's official linter for Rego code and checks for style issues, best practices, and potential bugs.
mpe| Option | Alias | Description | Required |
|---|---|---|---|
--file | -f | PolicyDomain YAML file(s) to lint | Yes |
--opa-flags | Additional flags for opa check | No | |
--no-opa-flags | Disable all OPA flags | No | |
--regal | Run Regal linting instead of standard validation | No |
mpe lint -f my-domain.yml
mpe lint -f domain1.yml -f domain2.yml
mpe lint -f my-domain.yml --opa-flags "--strict"
mpe lint -f my-domain.yml --no-opa-flags
mpe lint -f my-domain.yml --regal
mpe lint -f domain1.yml -f domain2.yml --regal
Linting YAML files...
✓ my-domain.yml: Valid YAML
✓ my-domain.yml: Valid Rego in library 'utils'
✓ my-domain.yml: Valid Rego in policy 'main'
✓ my-domain.yml: Valid Rego in policy 'admin'
✓ my-domain.yml: Valid Rego in mapper 'http-mapper'
---
All checks passed: 1 file(s) validated successfully
Linting YAML files...
✗ my-domain.yml (YAML)
Error: yaml: line 15: found character that cannot start any token
Linting YAML files...
✓ my-domain.yml: Valid YAML
✗ my-domain.yml (Rego in policy 'main')
Error: 1 error occurred: policy.rego:5: rego_parse_error: unexpected token
Linting YAML files...
✓ my-domain.yml: Valid YAML
✗ my-domain.yml (Reference error: library 'unknown-lib' not found)
Running Regal linting...
---
Regal linting passed: 1 file(s) validated successfully
Running Regal linting...
✗ my-domain.yml (Regal: use-assignment-operator in policy 'main' at line 12)
✗ my-domain.yml (Regal: no-whitespace-comment in library 'utils' at line 5)
---
Regal linting completed: 2 violation(s)
The lint command automatically builds PolicyDomainReference files before linting:
# If my-domain.yml is a PolicyDomainReference, it will be built first
mpe lint -f my-domain-ref.yml
Default OPA flags: --v0-compatible
Override via:
--opa-flags "--strict --v1-compatible"MPE_CLI_OPA_FLAGS="--strict"--no-opa-flags| Check | Description |
|---|---|
| YAML syntax | Valid YAML format |
| Rego syntax | Parseable Rego code |
| Rego compilation | Code compiles without errors |
| Package declaration | Each policy has package authz |
| Dependency resolution | All dependencies exist |
| Cross-domain references | External references are valid |
| OPA check | Additional OPA linting rules |
| Check | Description |
|---|---|
| Regal rules | Style, best practices, and bug detection via Regal's built-in rule set |
| Code | Description |
|---|---|
| 0 | All files valid |
| 1 | One or more files have errors |
Can you improve this documentation? These fine people already did:
IvanPazManetu & Greg HaskinsEdit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |