From 41fbf6eb1352b2996914d8311f624f82b3927902 Mon Sep 17 00:00:00 2001 From: Torin Sandall Date: Fri, 23 Aug 2019 14:19:27 -0400 Subject: [PATCH] docs: Update to show undefined example with != Fixes #1626 Signed-off-by: Torin Sandall --- docs/content/how-do-i-write-policies.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/docs/content/how-do-i-write-policies.md b/docs/content/how-do-i-write-policies.md index bb3ccc1737..0e7b6fecc9 100644 --- a/docs/content/how-do-i-write-policies.md +++ b/docs/content/how-do-i-write-policies.md @@ -83,9 +83,9 @@ 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 @@ -93,12 +93,17 @@ 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: @@ -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"`.