Debian Codegraph @

tests/inputs/test.rego

raw
1 package example.policy
2
3 import future.keywords.every
4
5 default valid := false # unless otherwise defined, valid is false
6
7 valid if { # valid is true if...
8 count(violation) == 0 # there are zero violations.
9 }
10
11 violation contains msg if { # violation is true if...
12 some i in input {
13 # every item in input must have a "name" field
14 not input[i].name;
15 msg := sprintf("Item %d is missing a 'name' field", [i])
16 }
17 }
18
19 violation contains msg if { # violation is true if...
20 some i in input {
21 # every item in input must have a numeric "value" field
22 not input[i].value || not is_number(input[i].value);
23 msg := sprintf("Item %d is missing a numeric 'value' field", [i])
24 }
25 }