

# Condition operators

A field test applies one or more condition operators to one field. This page describes the eight operators that version 1 of the record visibility configuration language supports. For each operator, it lists the fields it applies to and its operand, and shows how it matches present and absent values.

The following field test compares a record’s `department` label with two values.

```json
"customMetadata/department": {"StringEquals": ["finance", "legal"]}
```

In this test, `customMetadata/department` is the field, `StringEquals` is the operator, and the list is the operand. For the fields that you can test and the values they hold, see [Caller and record fields](registry-record-visibility-fields.md).

## Reading field tests
<a name="registry-record-visibility-operator-rules"></a>

A field test is a JSON object whose member names are operators, and it holds at least one operator. Version 1 accepts only the eight operator names on this page, spelled exactly as shown, with no aliases. Validation rejects any other name, so the service never ignores an unknown operator. It also never infers an operator from an operand’s shape.

The following rules apply to every field test:
+ Operators on one field combine with AND, and so do the field tests in a statement. A matching field test doesn’t grant or exclude anything by itself. For how tests and statements decide visibility, see [Does a statement match?](registry-record-visibility-evaluation.md#registry-record-visibility-statement-match) and [Which statements decide visibility?](registry-record-visibility-evaluation.md#registry-record-visibility-allow-deny-decision).
+ A list operand means any of its values for `StringEquals`, `StringEqualsIfExists`, and `ForAnyValue:StringEquals`. It means none of its values for `StringNotEquals`, and all of them for `ContainsAll`. For the maximum list length, see [Record visibility configuration limits](bedrock-agentcore-limits.md#registry-record-visibility-limits).
+ String operators take JSON string literals, either alone or as list entries. `StringEquals` and `StringEqualsIfExists` also accept a caller-value reference, as described in [Reference syntax and permitted positions](registry-record-visibility-caller-references.md#registry-record-visibility-caller-references-positions). Validation rejects a number or Boolean literal instead of converting it. Caller numbers and Booleans compare in their string forms, so write `"3"`, not `3`, and `"true"`, not `true`. For each value’s string form, see [Supported caller values](registry-record-visibility-fields.md#registry-record-visibility-claim-normalization).
+ Comparisons are exact. For details, see [Exact comparisons and author-supplied names](registry-record-visibility-fields.md#registry-record-visibility-field-comparison).

The table in each operator section shows runtime results for a configuration that passed validation:
+  **Match** – The field test holds.
+  **No match** – The field test doesn’t hold.

In those tables, an absent attribute is a caller field that the caller doesn’t have. It also covers a value in a shape that the service doesn’t read, such as `null` or `[]`. An absent label is a metadata field that the record’s approved revision has no value for. A missing referenced caller value works differently: the whole statement doesn’t apply to that caller, whatever the record’s label. For more information, see [Missing referenced values](registry-record-visibility-caller-references.md#registry-record-visibility-caller-references-missing).

## Combining operators and choosing claim cardinality
<a name="registry-record-visibility-combining-operators"></a>

A field test can hold several operators, and every one of them must hold. Each operator can appear only once in a field test, because a repeated member name is a duplicate key. To test several values with a string operator, use a list operand.

Validation checks every field test when you set the configuration. The following table lists the operators that one field test can combine on each kind of field.


| Field | Operators you can combine | Restrictions | 
| --- | --- | --- | 
|  `iam:accountId`, `iam:principalArn`  |  `StringEquals`, `StringNotEquals`  | These fields always have a value, so `Exists` is rejected. | 
|  `iam:organizationId`, `iam:principalTag/<key>`, and a `jwt:claim/<name>` tested as a single value |  `StringEquals`, `StringNotEquals`, `Exists`  | In an `Allow` statement, `StringNotEquals` requires `"Exists": true`, even beside `StringEquals`. In a `Deny` statement, `StringNotEquals` can appear without it. | 
| A `jwt:claim/<name>` tested as a set, `jwt:scopes`, `jwt:audiences`  |  `ForAnyValue:StringEquals`, `ContainsAll`, `Exists`  | None | 
|  `recordType`, `name`, `recordId`  |  `StringEquals`, `StringNotEquals`  | These fields always have a value, so `Exists` is rejected. | 
| A Text, Enum, or URL metadata field |  `StringEquals`, `StringNotEquals`, `Exists`. Alternatively, `StringEqualsIfExists` alone. |  `Exists` is optional beside `StringNotEquals`. `StringEqualsIfExists` can’t share its field test with another operator. | 
| A Boolean metadata field |  `Bool`, `Exists`. Alternatively, `BoolIfExists` alone. |  `BoolIfExists` can’t share its field test with another operator. | 

Validation rejects an operator that the table doesn’t list for the field. For example, it rejects an `IfExists` operator on a caller field, a string operator on a Boolean metadata field, and `Bool` on a Text field. To require a caller attribute, use `Exists`.

A `jwt:claim/<name>` field can hold a single value or a set, and its operators decide how the configuration tests it. The scalar operators `StringEquals` and `StringNotEquals` test the claim as a single value. The set operators `ForAnyValue:StringEquals` and `ContainsAll` test it as a set. AWS Identity and Access Management (IAM) fields are always single values, and `jwt:scopes` and `jwt:audiences` are always sets.

A claim has one cardinality across the whole configuration, including statements with different effects. Validation rejects a configuration that tests one claim with both a scalar operator and a set operator. The error names both statements.

 `Exists` and caller-value references don’t fix a claim’s cardinality. A scalar operator with a list operand still tests one value against alternatives, not set membership.

To choose a claim’s cardinality, check how your identity provider issues the claim:
+ If the claim can arrive as an array, even a one-element array, use set operators. A usable array is a set, and a scalar operator never matches it. An unsupported shape is absent and follows each operator’s absent row. A set operator reads a supported scalar as a one-element set, so it can test both shapes.
+ Use scalar operators only for a claim that your identity provider always issues as a single supported value: a string, number, or Boolean, which compare as strings.

For the values that each claim shape supplies, see [Supported caller values](registry-record-visibility-fields.md#registry-record-visibility-claim-normalization).

## Missing record labels
<a name="registry-record-visibility-record-absence"></a>

A record’s label is absent when its approved revision has no value for the metadata field. Declaring a field in the schema doesn’t give every record a label. Every record whose type’s schema doesn’t declare the field lacks it. So does a revision approved before the field was declared, and a revision that omits an optional field. For details, see [customMetadata/<key>](registry-record-visibility-fields.md#registry-record-visibility-custom-metadata).

**Some tests match records whose label is absent**  
A test can match records that you never labeled. Unguarded `StringNotEquals`, `StringEqualsIfExists`, and `BoolIfExists` match a record whose label is absent. In an `Allow` statement, such a test can grant unlabeled records, including every record of a type whose schema lacks the field. In a `Deny` statement, it hides them.  
Positive tests (`StringEquals`, `Bool`, and `Exists`) don’t match an absent label. So a `Deny` statement that tests the label positively doesn’t hide an unlabeled record.

A match on an absent label isn’t a grant by itself. The record must be approved, and the caller’s request must be authorized. The statement’s other tests must match, and the statement must apply to the caller. A matching `Deny` statement still hides the record. For example, a `Deny` statement with a positive `recordId` or `recordType` test can hide an unlabeled record, because those fields always have a value.

Record and caller fields differ in one rule. On a metadata field, `"Exists": true` beside `StringNotEquals` is optional. Add it to keep the test from matching unlabeled records. On an optional caller field in an `Allow` statement, it’s required. So an `Allow` statement never grants through negation to a caller who lacks the attribute.

A missing referenced caller value is also different from a missing label. It makes the whole statement not apply, even with `StringEqualsIfExists`. For more information, see [Missing referenced values](registry-record-visibility-caller-references.md#registry-record-visibility-caller-references-missing).

To grant only records labeled with permitted values, list those values with `StringEquals`. Unlabeled records and newly introduced values then stay hidden unless another statement grants them. For the strict and permissive forms compared on the same records, see [Unlabeled records and new values](registry-record-visibility-examples.md#registry-record-visibility-examples-unlabeled). Before you add or change a schema field, see [Changing the schema](registry-custom-metadata-schema.md#registry-custom-metadata-schema-change).

## StringEquals
<a name="registry-record-visibility-string-equals"></a>

 `StringEquals` matches when the field’s single value equals the operand, or equals any string in an operand list. It applies to IAM caller fields, a JSON Web Token (JWT) claim tested as a single value, `recordType`, `name`, `recordId`, and Text, Enum, and URL metadata fields. It doesn’t apply to `jwt:scopes`, `jwt:audiences`, or Boolean metadata fields.

Its operand is a string or a nonempty list of strings. A literal for a field with a fixed format, such as `recordId` or `iam:accountId`, must use that format. You can combine `StringEquals` with `StringNotEquals` and `Exists`. For more information, see [Combining operators and choosing claim cardinality](#registry-record-visibility-combining-operators).

The following fragment tests a caller’s `department` claim. The same results apply to the record test `"customMetadata/department": {"StringEquals": "finance"}`.

```json
"jwt:claim/department": {"StringEquals": "finance"}
```

The following table shows the result for each value of the tested field.


| Value of the tested field | Field-test result | 
| --- | --- | 
|  `"finance"`  | Match | 
|  `"legal"` or `"Finance"`  | No match | 
|  `["finance"]`, a one-element array claim | No match | 
| Attribute absent, or label absent | No match | 

A list operand, such as `["finance", "legal"]`, matches either value but still tests a single value. A claim that arrives as an array never matches. To test membership, use [ForAnyValue:StringEquals](#registry-record-visibility-for-any-value-string-equals).

An `Allow` statement with this test grants nothing to a caller who lacks the attribute, and doesn’t grant a record that lacks the label. A `Deny` statement with this test excludes neither that caller nor that record. Other statements still apply. For more information, see [Which statements decide visibility?](registry-record-visibility-evaluation.md#registry-record-visibility-allow-deny-decision).

On a Text, Enum, or URL metadata field, the operand can instead be a caller-value reference, such as `{"ref": "iam:principalTag/department"}`. If the caller lacks the referenced value, the whole statement doesn’t apply. For more information, see [Reference syntax and permitted positions](registry-record-visibility-caller-references.md#registry-record-visibility-caller-references-positions).

## StringNotEquals
<a name="registry-record-visibility-string-not-equals"></a>

 `StringNotEquals` matches when the field is absent, or when its single value equals none of the operand strings. With a list operand, such as `["finance", "legal"]`, the value must differ from every listed string. It applies to the same fields as [StringEquals](#registry-record-visibility-string-equals). Its operand is a string or a nonempty list of strings, and it can’t be a caller-value reference.

 `StringNotEquals` isn’t the opposite of `StringEquals`. A caller set, even a one-element array, matches neither of them. Absence also has different consequences for caller and record fields, so the following two tables show each side.

On an optional caller field, an `Allow` statement must pair `StringNotEquals` with `"Exists": true`. So the following caller fragment is valid only in a `Deny` statement. It’s meant to exclude every caller who isn’t an employee.

```json
"jwt:claim/employment_type": {"StringNotEquals": "employee"}
```

The following table shows the result for each value of the caller’s claim.


| Caller’s `employment_type` claim | Field-test result | 
| --- | --- | 
|  `"contractor"`  | Match | 
|  `"employee"`  | No match | 
|  `["contractor"]`, a usable one-element array | No match | 
| Attribute absent, including `[]` or an array that contains `null` or an object | Match | 

This `Deny` statement excludes callers who lack the claim or send it in an unsupported shape. It doesn’t exclude a caller who sends a usable array, so make sure that your identity provider issues the claim as a single string. With `"Exists": true` in the test, as an `Allow` statement requires, an absent attribute doesn’t match. To grant everyone except one department, including callers without the attribute, see [Everyone except one department](registry-record-visibility-examples.md#registry-record-visibility-examples-everyone-except).

The following record fragment tests a Text metadata field. It’s valid in either effect.

```json
"customMetadata/department": {"StringNotEquals": "finance"}
```

The following table shows the result for each stored label.


| Stored `department` label | Field-test result | 
| --- | --- | 
|  `"legal"`  | Match | 
|  `"Finance"`  | Match, because comparisons are case-sensitive | 
|  `"finance"`  | No match | 
| Label absent | Match | 

In an `Allow` statement, this unguarded test grants records without the label. It also grants records with values that you haven’t listed yet, such as a new department. In a `Deny` statement, it hides those same records. To keep unlabeled records out of the test, add `"Exists": true`. To grant only permitted values, list them with `StringEquals` instead. For both forms, see [Unlabeled records and new values](registry-record-visibility-examples.md#registry-record-visibility-examples-unlabeled).

## StringEqualsIfExists
<a name="registry-record-visibility-string-equals-if-exists"></a>

 `StringEqualsIfExists` matches when a record has no label for the metadata field. It also matches when the label equals the operand or any string in an operand list. It applies only to Text, Enum, and URL metadata fields, not to caller fields or to `recordType`, `name`, and `recordId`. Its operand is the same as for `StringEquals`: a string, a nonempty list of strings, or a caller-value reference. It must be the only operator in its field test.

The following fragment assumes that the schema declares `department` as a Text field.

```json
"customMetadata/department": {"StringEqualsIfExists": "finance"}
```

The following table shows the result for each stored label.


| Stored `department` label | Field-test result | 
| --- | --- | 
|  `"finance"`  | Match | 
|  `"legal"`  | No match | 
| Label absent | Match | 

The test matches every record without the label, including every record of a type whose schema doesn’t declare `department`. An `Allow` statement with it grants those records, and a `Deny` statement hides them. For more information, see [Missing record labels](#registry-record-visibility-record-absence).

With a caller-value reference as the operand, the test also matches records without the label. If the caller lacks the referenced value, the whole statement doesn’t apply, as described in [Missing referenced values](registry-record-visibility-caller-references.md#registry-record-visibility-caller-references-missing).

## Bool
<a name="registry-record-visibility-bool"></a>

 `Bool` matches when a Boolean metadata field’s stored value equals the operand. It applies only to Boolean metadata fields, and its operand must be the JSON value `true` or `false`. Quoted Booleans aren’t valid operands. You can combine `Bool` with `Exists`. For more information, see [Combining operators and choosing claim cardinality](#registry-record-visibility-combining-operators). To test a Boolean JWT claim, use a string operator with `"true"` or `"false"`. For the string forms, see [Supported caller values](registry-record-visibility-fields.md#registry-record-visibility-claim-normalization).

The following field-test fragment assumes that the schema declares `restricted` as a Boolean field.

```json
"customMetadata/restricted": {"Bool": true}
```

The following table shows the result for each stored value.


| Stored `restricted` value | Field-test result | 
| --- | --- | 
|  `true`  | Match | 
|  `false`  | No match | 
| Label absent | No match | 

A `Deny` statement with this test doesn’t hide a record that lacks the label. To match missing labels as well, use [BoolIfExists](#registry-record-visibility-bool-if-exists). A field match contributes to the statement’s decision only when its other tests match. For more information, see [Which statements decide visibility?](registry-record-visibility-evaluation.md#registry-record-visibility-allow-deny-decision).

## BoolIfExists
<a name="registry-record-visibility-bool-if-exists"></a>

 `BoolIfExists` matches when a record has no label for a Boolean metadata field, or when the stored value equals the operand. It applies only to Boolean metadata fields, not to caller fields. Its operand must be the JSON value `true` or `false`, not a quoted Boolean, and it must be the only operator in its field test.

The following fragment assumes that the schema declares `restricted` as a Boolean field.

```json
"customMetadata/restricted": {"BoolIfExists": true}
```

The following table shows the result for each stored value.


| Stored `restricted` value | Field-test result | 
| --- | --- | 
|  `true`  | Match | 
|  `false`  | No match | 
| Label absent | Match | 

The test matches every record without the label, including every record of a type whose schema doesn’t declare `restricted`. So a `Deny` statement with this test hides unlabeled records along with records labeled `true`, and an `Allow` statement grants both. For more information, see [Missing record labels](#registry-record-visibility-record-absence). For a `Deny` statement that hides restricted records from every grant, see [Hide restricted records from every grant](registry-record-visibility-examples.md#registry-record-visibility-examples-exclude-restricted).

## ForAnyValue:StringEquals
<a name="registry-record-visibility-for-any-value-string-equals"></a>

 `ForAnyValue:StringEquals` matches when at least one caller value equals one of the operand values. It applies to JWT claims tested as sets, `jwt:scopes`, and `jwt:audiences`. It doesn’t apply to IAM or record fields. Its operand is a string or a nonempty list of strings.

The following principal-test fragment requires membership in either group.

```json
"jwt:claim/groups": {"ForAnyValue:StringEquals": ["finance-readers", "finance-ops"]}
```

The following table shows the result for each shape of the caller’s claim.


| Validated `groups` claim | Field-test result | 
| --- | --- | 
|  `"finance-readers"` (scalar) | Match | 
|  `["finance-readers"]` (one-element array) | Match | 
|  `["auditors", "finance-ops"]`  | Match | 
|  `["auditors"]`  | No match | 
| Attribute absent, including `null`, `[]`, or an unsupported shape | No match | 

You can combine this operator with `ContainsAll` or `Exists`. Across the configuration, the same claim can’t also use `StringEquals` or `StringNotEquals`. For more information, see [Combining operators and choosing claim cardinality](#registry-record-visibility-combining-operators). For supported shapes, see [Supported caller values](registry-record-visibility-fields.md#registry-record-visibility-claim-normalization).

An `Allow` statement with this test grants nothing to a caller whose attribute is absent. A `Deny` statement with it excludes nothing from that caller, so a broad `Allow` statement still grants records to that caller. To exclude callers without the claim as well, require it with `Exists` in the `Allow` statement instead of a `"*"` principal. For this pattern, see [Everyone except members of a group](registry-record-visibility-examples.md#registry-record-visibility-examples-everyone-except-group).

## ContainsAll
<a name="registry-record-visibility-contains-all"></a>

 `ContainsAll` matches when the caller’s set contains every value in the operand list. The set can also hold values that you didn’t list, in any order. It applies to JWT claims tested as sets, `jwt:scopes`, and `jwt:audiences`. It doesn’t apply to IAM or record fields. Its operand must be a nonempty list of strings, not a single string or a caller-value reference.

The following principal-test fragment requires both groups.

```json
"jwt:claim/groups": {"ContainsAll": ["finance", "reader"]}
```

The following table shows the result for each shape of the caller’s claim.


| Validated `groups` claim | Field-test result | 
| --- | --- | 
|  `["finance", "reader"]`  | Match | 
|  `["reader", "ops", "finance"]`  | Match | 
|  `["finance"]`  | No match, because `reader` is missing | 
|  `"finance"` (scalar, read as a one-element set) | No match | 
| Attribute absent, including `null`, `[]`, or an unsupported shape | No match | 

An `Allow` statement with this test grants nothing to a caller whose attribute is absent. A `Deny` statement with it excludes nothing from that caller.

No operator restricts a caller’s set to only the values in a list. Values that you didn’t list never prevent a match with `ContainsAll` or `ForAnyValue:StringEquals`.

You can combine `ContainsAll` with `ForAnyValue:StringEquals` or `Exists` on the same claim. The claim then can’t use `StringEquals` or `StringNotEquals` anywhere in the configuration. For a test that requires one group plus any of several others, see [Require membership in all listed groups](registry-record-visibility-examples.md#registry-record-visibility-examples-jwt-groups-all).

## Exists
<a name="registry-record-visibility-exists"></a>

 `Exists` matches when the field has a value. It applies to every declared metadata field, including Boolean fields, and to the caller fields that can be absent. Those are `iam:organizationId`, `iam:principalTag/<key>`, `jwt:claim/<name>`, `jwt:scopes`, and `jwt:audiences`. It doesn’t apply to `iam:accountId`, `iam:principalArn`, `recordType`, `name`, or `recordId`, which always have a value.

Its operand must be the JSON value `true`. No operator tests for absence alone, so `"Exists": false` is rejected. `Exists` can stand alone, or share a field test with the scalar, set, or `Bool` operators that the field allows. It can’t share a field test with an `IfExists` operator. For more information, see [Combining operators and choosing claim cardinality](#registry-record-visibility-combining-operators).

The following fragment requires a `department` label. The same results apply to `{"Exists": true}` on any field that `Exists` applies to, including a caller field.

```json
"customMetadata/department": {"Exists": true}
```

The following table shows the result for each kind of value.


| Value of the tested field | Field-test result | 
| --- | --- | 
| A string, including an empty string, `""`  | Match | 
| A Boolean label, including `false`  | Match | 
| A caller set, including a one-element array | Match | 
| Attribute absent, including `null`, `[]`, an object, an unsupported array, or a `scope` string that is empty or holds only spaces (U\+0020) | No match | 
| Label absent | No match | 

Beside `StringNotEquals`, `Exists` keeps the negation from matching an absent value. It’s required on an optional caller field in an `Allow` statement, and optional on a metadata field. For how that choice affects unlabeled records, see [Missing record labels](#registry-record-visibility-record-absence).