Validates a resource against a shape.
Enforces all shape constraints including type, cardinality, closed-shape checks, and custom validators.
Unknown and missing entries are both rejected; all declared entries are required unless marked optional
by the shape. The return value is narrowed to Instance<T> where T is the projection Template bonded
to the shape's model slot.
By default, resources accept captive reference expansion to unbounded depth. To enforce a strict update process
that admits only bare references, set depth to 0 to reject all expansion; set it to a positive value to cap
the nesting depth admitted.
When the projection template is not bonded to the shape (for example, at API boundaries where shape and the
requested projection arrive as independent inputs) use the projection-form overload that takes model as a
separate argument.
The function is idempotent on a specific shape: on re-validation against the same shape, the previous association is trusted without repeating the validation process, so that you can safely re-validate defensively.
The value to validate as a resource
Validation options
Readonlyshape: Lazy<ResourceShape & { model: T }>The Lazy ResourceShape defining validation constraints
Optional Readonlymodel?: falseOmit (or pass false) to validate value as a full resource instance against the shape
Optional Readonlyentry?: stringOptional Readonlydepth?: numberMaximum nesting depth for expanding captive reference values as inline target resource states;
each expansion level counts against the budget; 0 rejects all expansion, accepting bare IRI references only;
if omitted, no depth limit is enforced
A Relay resolving to either { value } on success or { trace } on failure; on success, the
value is an immutable copy validated against a verified and flattened copy of the shape
(see resource); on failure, the trace describes
constraint violations
If the shape is malformed (see resource)
Validates a retrieval result against a shape under an explicit projection template.
Narrows the admissibility check to the surface projected by model: constraints declared in shape are enforced
only for keys named in model, recursing into nested shapes for nested templates and dropping any shape leaf
without a counterpart in model. Intended for call sites that receive shape and the requested projection as
independent inputs, such as response-validating adapters or API boundary validators where the admissible surface
is fixed and the projection varies per request.
Differs from the bonded-shape resource overload in three ways:
model are not enforced; unrequested required fields do
not trigger minCount violations.model.Instance<T> where T is inferred from model.
The function is idempotent on a specific (shape, model) combination: on re-validation against the same shape
and model the previous association is trusted without repeating the validation process, so that you can safely
re-validate defensively.
The value to validate as a retrieval result
Validation options
Readonlyshape: Lazy<ResourceShape>The Lazy ResourceShape defining the admissible surface
Readonlymodel: TProjection Template narrowing the admissibility check to the projected surface and the
return value to Instance<T>
Optional Readonlyentry?: stringA Relay resolving to either { value } on success or { trace } on failure; on success, the
value is an immutable copy validated against a verified and flattened copy of the shape narrowed by model
(see resource); on failure, the trace describes constraint violations
If the shape is malformed (see resource)
Validates a template against a shape.
Enforces type and structural constraints; value constraints are skipped as query values are placeholders.
Cardinality is checked for shape consistency (scalar if maxCount is 1, singleton tuple otherwise);
missing entries are accepted as not requested. Bindings whose probe — path and pipe — fails to resolve
against the shape are rejected with an atomic trace under the binding key.
By default, templates support the full query language, including aggregate transforms and nested expansion.
When exposing endpoints to untrusted clients, restrict query complexity as required by setting plain
to true, depth to 0 or a positive value, and/or limit to a maximum result set size.
Retrieval forms for linked resources differ by shape kind:
| Shape kind | IRI reference | Nested template |
|---|---|---|
| Embedded resource — direct ResourceShape | — | ✓ |
| Standalone resource — ReferenceShape wrapper | ✓ | ✓ |
An IRI reference is a bare IRI reference placeholder retrieving only the identifier; as a placeholder it is
never resolved on decoding, so it admits any IRI reference (the empty string, a root-relative or relative
reference, or an absolute IRI). A nested template is a Template retrieving the requested subset of the
linked resource, validated against its target shape and subject to the depth budget (if any). Setting depth
to 0 disables the nested-template form for references while still accepting IRI references.
The function is idempotent on a specific shape: on re-validation against the same shape, the previous association is trusted without repeating the validation process, so that you can safely re-validate defensively.
The value to validate as a template
Validation options
Readonlyshape: Lazy<ResourceShape>The Lazy ResourceShape defining the expected structure
Readonlymodel: trueMust be true to validate value as a retrieval template rather than as an instance
Optional Readonlyplain?: booleanWhether to reject aggregate transforms (count, sum, min, max, avg); true rejects
any binding containing aggregate transforms; defaults to false
Optional Readonlydepth?: numberOptional Readonlylimit?: numberMaximum value for the # pagination constraint in queries;
a positive value caps the result set: a query whose # exceeds it, or is 0 (unbounded), is rejected, and a
query omitting # has the limit injected as a default; a value of 0, like omitting the option, is itself
unbounded, enforcing no limit and injecting no #
A Relay resolving to either { value } on success or { trace } on failure; on success, the
value is an immutable copy validated against a verified and flattened copy of the shape
(see resource); on failure, the trace describes constraint violations
If the shape is malformed (see resource)
Validates resources and templates against shapes.