> For the complete documentation index, see [llms.txt](https://docs.guardianservice.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.guardianservice.app/technical-information/users/standard-registry-users-schemas-and-policies/policies/available-policy-workflow-blocks/documentvalidatorblock/configure-source-validations.md).

# Configure Source Validations

Add a cross-document check to a documentValidatorBlock.

Add a Source Validation entry to a `documentValidatorBlock` so the block checks the incoming document against documents already held by the policy.

## Prerequisites

* You are signed in as a Standard Registry user.
* The policy is in **Draft** status and open in the [Policy Configurator](/technical-information/users/standard-registry-users-schemas-and-policies/policies/policy-configurator.md).
* The policy contains a `documentValidatorBlock`, and the schema of the documents you want to query is published or available in the policy.

## Steps

### 1. Open the block's Source Validations

1. Select the `documentValidatorBlock` in the tree.
2. In the properties panel, expand **Source Validations**.
3. Add an entry. It appears as **Source Validation 0**, and further entries are numbered in order.

### 2. Define the query

1. Set **Source Collection** to **VC Document** or **VP Document**.
2. Set **Schema** to the schema the source documents use.
3. Optionally set a **Fail Message**, which is placed in front of the generated failure detail.
4. Optionally narrow the query by ownership using **Owned by User**, **Owned by Group**, **Assigned to User**, and **Assigned to Group**.

### 3. Add source filters (optional)

Under **Source Filters**, add a filter for each field-level restriction on the source documents.

* **Field**, the path on the source document, for example `credentialSubject.0.status`.
* **Operator**, one of Equal, Not Equal, In, Not In, Greater Than, Greater Than or Equal, Less Than, Less Than or Equal.
* **Value Type**, either **Value** for a literal or **Variable (Input Doc)** to read the comparison value from the incoming document.
* **Value**, the literal or the path, depending on the value type.

Filters decide which documents are candidates. They do not decide whether the entry passes.

### 4. Add conditions

Under **Conditions**, add a condition for each relationship that must hold between a candidate document and the incoming document.

1. Set **Left Source** to **Value** or **Input Document**. If it is a document, set **Left Field** to the path.
2. Choose the **Operator**.
3. Set **Right Source** to **Value**, **Input Document**, or **Source Document**, and set **Right Field** to the path where applicable.

### 5. Wire the error output

Confirm the block's error output is connected to the step that should handle a failed check. A failed Source Validation emits the block's error event.

### 6. Save and test

Save the policy, then exercise the step in a [Dry Run](/technical-information/users/standard-registry-users-schemas-and-policies/policies/dry-run.md). Submit a document that should pass, and one that should fail, and confirm the failure message names the condition you expect.

## Result

When the block runs, it queries for documents matching the schema, the ownership settings, and the source filters, then tests each candidate against the conditions. The entry passes as soon as one candidate satisfies all of them. If none does, the block emits its error event with a message naming the failed conditions and the number of source documents checked, prefixed by your fail message if you set one.

## Troubleshooting

**The check always fails, even with a document that should match.**\
Confirm the query is returning anything at all. Remove the source filters and the ownership restrictions, and add them back one at a time. An empty result set fails the entry the same way a non-matching candidate does.

**The check passes when it should not.**\
Remember the entry passes if any one candidate satisfies all conditions. Narrow the candidate set with Source Filters rather than adding more conditions.

## Related

* Concept: [Document Validator Block Source Validations](/technical-information/users/standard-registry-users-schemas-and-policies/policies/available-policy-workflow-blocks/documentvalidatorblock/document-validator-block-source-validations.md)
* Reference: [documentValidatorBlock](/technical-information/users/standard-registry-users-schemas-and-policies/policies/available-policy-workflow-blocks/documentvalidatorblock.md)
