> For the complete documentation index, see [llms.txt](https://php-fhir-tools.ardenexal.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://php-fhir-tools.ardenexal.net/validation/references.md).

# Reference & Target Profile Validation

Validates that a `Reference`- or canonical-typed property points to a resource conforming to at least one of the declared target profile URLs, via `FHIRTargetProfileValidator`, driven by the `#[FHIRTargetProfile]` attribute (which carries a `targetProfiles` list).

{% hint style="info" %}
Reference resolution is pluggable through `FHIRReferenceResolverInterface`. Configure a resolver on the [Configuration](/validation/configuration.md) page. The default `NullFHIRReferenceResolver` skips all target-profile checks silently.
{% endhint %}

## How it works

For each `Reference` object (and each element of an array of references), the validator delegates resolution to the configured `FHIRReferenceResolverInterface::resolve()`:

1. If the resolver returns `null` (including the `NullFHIRReferenceResolver` default), the check is **skipped silently** — no violation.
2. If the resolved object carries no `#[FHIRProfile]` attribute, a WARNING is emitted: `Cannot verify target profile conformance: the resolved object carries no #[FHIRProfile] attribute.`
3. If the resolved object has profiles but none match any URL in `targetProfiles`, an ERROR is emitted listing expected vs. actual profile URLs.

Canonical-typed values (raw `string` or `\Stringable` objects such as `CanonicalPrimitive`) are always skipped — they cannot be resolved to an in-process PHP object. Null values are skipped.

Both messages are overridable via the `FHIRTargetProfile` key in `FHIRValidationMessageRegistry`.

## Resolver examples

See [Configuration](/validation/configuration.md) for wiring a Bundle-scanning or registry-based resolver that maps `Reference` objects to their target PHP model.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://php-fhir-tools.ardenexal.net/validation/references.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
