Files
releases/docs/docs/policy-reference/_examples/strings/sprintf/deny-message/input.json
T
Dean Chen af3678f6cf docs(policy-reference): add examples for common built-ins (#8913)
## Description

Incremental pass on #3786: add `PlaygroundExample` blocks for a handful
of frequently used built-ins that had no examples yet.

| Built-in | Example |
|---|---|
| `units.parse` | Compare container memory limits expressed with
different unit suffixes |
| `object.get` | Read an optional label with a default (`env` → `dev`) |
| `startswith` | Restrict HTTP paths to `/api/v1/` |
| `sprintf` | Build a deny message with user/role/action/resource |
| `intersection` | Check required OAuth-style scopes are present |
| `array.concat` | Merge a base registry allowlist with tenant extras |

Each example follows the existing layout under
`docs/docs/policy-reference/_examples/` (`policy.rego`, `input.json`,
`intro.md`, `output.json`, …). Outputs were generated with `opa eval`
(same approach as `docs/bin/eval-examples.sh`).

`units.parse` was suggested in the issue thread as a good starting
point.

## Checklist

- [x] I have read the [contribution
guidelines](https://www.openpolicyagent.org/docs/latest/contributing/).
- [x] I have added/updated tests for my change (docs-only; examples
evaluate cleanly with `opa eval`).
- [x] All new/updated docs follow the existing style of nearby examples
(`count`, `sum`, `contains`, …).

Closes nothing by itself — this is partial progress on #3786.

---------

Signed-off-by: Dean Chen <51218137+locker95@users.noreply.github.com>
Signed-off-by: Dean Chen <862469039@qq.com>
2026-08-05 21:15:22 -05:00

7 lines
90 B
JSON

{
"user": "alice",
"role": "guest",
"action": "delete",
"resource": "orders/42"
}