Skip to content

Commit

Permalink
document isEmpty operator (#157)
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Disselkoen <cdiss@amazon.com>
  • Loading branch information
cdisselkoen authored Jan 14, 2025
1 parent 18538d4 commit bdc973a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
3 changes: 2 additions & 1 deletion docs/collections/_other/doc-history.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ The following table tracks changes to the Cedar language version. The language v

| Cedar<br/>Version | Description | Cedar SDK<br/>Version(s) | Date |
| --- | --- | --- | --- |
| 4.1 | Entity tags [rfc#82](https://github.com/cedar-policy/rfcs/blob/main/text/0082-entity-tags.md)<br/>Annotations without values [cedar#1231](https://github.com/cedar-policy/cedar/pull/1231) | 4.2.0 | October 7, 2024
| 4.2 | `isEmpty` operator [cedar#1358](https://github.com/cedar-policy/cedar/pull/1358) | 4.3.0 | TBD
| 4.1 | Entity tags [rfc#82](https://github.com/cedar-policy/rfcs/blob/main/text/0082-entity-tags.md)<br/>Annotations without values [cedar#1231](https://github.com/cedar-policy/cedar/pull/1231) | 4.2.0 - 4.2.2 | October 7, 2024
| 4.0 | Reserve `__cedar` identifier for internal use [rfc#52](https://github.com/cedar-policy/rfcs/blob/main/text/0052-reserved-namespaces.md)<br/>Remove unspecified entities [rfc#55](https://github.com/cedar-policy/rfcs/blob/main/text/0055-remove-unspecified.md)<br/>Disallow shadowing definitions in the empty namespace [rfc#70](https://github.com/cedar-policy/rfcs/blob/main/text/0070-disallow-empty-namespace-shadowing.md)<br/>Allow `EntityOrCommon` field in JSON schema [cedar#1060](https://github.com/cedar-policy/cedar/pull/1060)<br/>Disallow `Bool`, `Boolean`, `Entity`, `Extension`, `Long`, `Record`, `Set`, and `String` as common type names in schemas [cedar#1150](https://github.com/cedar-policy/cedar/pull/1150) | 4.0.0 - 4.1.0 | September 16, 2024 |
| 3.4 | JSON format for policy sets [cedar#549](https://github.com/cedar-policy/cedar/issues/549) | 3.3.0 - 3.4.0 | August 19, 2024 |
| 3.3 | References between common types [cedar#154](https://github.com/cedar-policy/cedar/issues/154) | 3.2.0 - 3.2.4 | May 17, 2024 |
Expand Down
4 changes: 2 additions & 2 deletions docs/collections/_policies/json-format.md
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ An JsonExpr object is an object with a single key that is any of the following.
+ [`Var`](#JsonExpr-Var)
+ [`Slot`](#JsonExpr-Slot)
+ [`Unknown`](#JsonExpr-Unknown)
+ [`!` or `neg` operators](#JsonExpr-neg)
+ [`!`, `neg`, and `isEmpty` operators](#JsonExpr-neg)
+ [Binary operators: `==`, `!=`, `in`, `<`, `<=`, `>`, `>=`, `&&`, `||`, `+`, `-`, `*`, `contains`, `containsAll`, `containsAny`, `hasTag`, `getTag`](#JsonExpr-binary)
+ [`.`, `has`](#JsonExpr-has)
+ [`is`](#JsonExpr-is)
Expand Down Expand Up @@ -811,7 +811,7 @@ The value of this key is one of the strings `?principal` or `?resource` and act

The value of this key is an object with a single key name, whose value is the name of the unknown. This is used for partial-evaluation. In particular, these values may appear in the JSON rendering of residuals.

#### `!` or `neg` operators {#JsonExpr-neg}
#### `!`, `neg`, and `isEmpty` operators {#JsonExpr-neg}

The value of this key is an object with a single key argument, whose value is itself an [JsonExpr object](#JsonExpr-objects).

Expand Down
16 changes: 16 additions & 0 deletions docs/collections/_policies/syntax-operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,22 @@ In the examples that follow, those labeled `//error` both evaluate and validate

The examples that evaluate to a result but fail to validate reference the empty-set literal `[]`. See [valid sets](syntax-datatypes.html#datatype-set) for more info.

### `.isEmpty()` \(set emptiness test\) {#function-isEmpty}

**Usage:** `<set>.isEmpty()`

Function that evaluates to `true` if the set is empty.
The receiver must be of type `set` or evaluation produces an error.

#### Examples:
{: .no_toc }

```cedar
[1, -22, 34].isEmpty() // Evaluates to false
[].isEmpty() // Evaluates to true
"".isEmpty() // Error - operand is a string, not a set
```

## IP address functions {#functions-ipaddr}

Use these functions to test characteristics of IP addresses and ranges.
Expand Down
2 changes: 1 addition & 1 deletion docs/js/hljs-cedar.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bdc973a

Please sign in to comment.