Skip to content

Commit

Permalink
docs: Update to show undefined example with !=
Browse files Browse the repository at this point in the history
Fixes #1626

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
  • Loading branch information
tsandall committed Aug 23, 2019
1 parent 74d67c5 commit 41fbf6e
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions docs/content/how-do-i-write-policies.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,27 @@ You can define a new concept using a rule. For example, `v` below is true if th
v { "hello" == "world" }
```

If we evaluate `v`, the result is `undefined` because the body
of the rule never evaluates to `true`. As a result, the document generated by
the rule is not defined.
If we evaluate `v`, the result is `undefined` because the body of the rule never
evaluates to `true`. As a result, the document generated by the rule is not
defined.

```live:eg/undefined:query:hidden
v
```
```live:eg/undefined:output:expect_undefined
```

Expressions that refer to undefined values are also undefined.
Expressions that refer to undefined values are also undefine. This includes comparisons such as `!=`.

```live:eg/undefined/expression:query:merge_down
v == true
```
```live:eg/undefined/expression:output:expect_undefined
```live:eg/undefined/expression:output:expect_undefined,merge_down
```
```live:eg/undefined/other_expression:query:merge_down
v != true
```
```live:eg/undefined/other_expression:output:expect_undefined
```

We can define rules in terms of [Variables](#variables) as well:
Expand Down Expand Up @@ -181,7 +186,7 @@ sites = [{"name": "prod"}, {"name": "smoke1"}, {"name": "dev"}]
And
```live:eg/references/basic:module
r { sites[_].name == "prod" }
```
```

The rule `r` above asserts that there exists (at least) one document within `sites` where the `name` attribute equals `"prod"`.

Expand Down

0 comments on commit 41fbf6e

Please sign in to comment.