Validates a resource against a shape.
Reports what a resource states wrongly, so that a caller may refuse it before it reaches the store holding it, and hands back the resource itself where it passes, typed as the shape describes it. Every member the shape declares is held to it and one it doesn't declare is rejected, the shape being closed; a member the shape admits no value for may be left out.
A captive member is expanded to whatever depth it reaches. Where a caller must be held to bare links, state
depth as 0 to refuse every expansion, or as the nesting it may ask for.
Revalidating a value costs nothing where the second call asks for no more than the first: the earlier verdict is read off the value itself, so a caller may validate defensively wherever it is unsure.
The shape the resource is matched against
The value to validate as a resource
Validation options
Readonlyshape: SThe shape the resource is matched against, possibly deferred to break definition cycles
Optional Readonlymodel?: falseOmitted, or false, to validate value as a resource in its own right
Optional Readonlyentry?: stringThe identifier the resource is expected to be named by, where it states one at all
Optional Readonlydepth?: numberThe nesting a captive member may be expanded to, counting each resource it descends into; 0
refuses every expansion while still admitting the identifier naming the resource
A Relay carrying the resource where it passes and a trace of the violations where it doesn't
TraceError Where shape is malformed
Validates a retrieved resource against a shape, narrowed by the template that requested it.
Reports what a retrieval brought back wrongly, so that a caller may refuse a malformed response before reading it, and hands back the resource typed as the template asked for it. Only the members the template names are held to the shape, so a partial retrieval passes on its own terms, and a member the template didn't ask for is rejected, the caller having nowhere to put it. Reach for this where the shape fixes what may be asked for and the template varies from one request to the next.
The custom checks a shape states never run against a retrieved resource, even one the template asked for whole: they run only where a whole resource is validated in its own right.
The template states which values are wanted and no longer what they are, so every type comes from the shape: the resource comes back as Match resolves it, keyed down to the members the template named. A polymorphic member, a projection column and a localised member come back as wide as the shape describes them.
Revalidating a value against the same shape and template costs nothing, as validating a resource explains.
The shape the resource is matched against
The template the resource was requested by
The value to validate as a retrieved resource
Validation options
Readonlyshape: SThe shape the resource is matched against, possibly deferred to break definition cycles
Readonlymodel: MThe template that requested it, narrowing both what is checked and what comes back
Optional Readonlyentry?: stringThe identifier the resource is expected to be named by, where it states one at all
A Relay carrying the resource where it passes and a trace of the violations where it doesn't
TraceError Where shape is malformed
Validates a retrieval template against a shape.
Reports each slot of a template that asks for something the shape cannot give, so that a caller may refuse a request before issuing it, and hands back the template itself where it passes, held to what the service guarantees. A template describes what to retrieve rather than what is held, so the value-domain constraints are left alone and a slot the template omits is simply not asked for.
A template may draw on the full query language, including aggregate transforms and nested expansion. Hold an
untrusted caller to what the service will serve: plain refuses the aggregate transforms, depth caps the
nesting, and limit caps the page.
A member reaching a standalone resource may be asked for as the identifier naming it or as a template standing for
the resource behind it; an embedded one, having no identifier of its own, only as a template. Stating depth as
0 thus leaves a link retrievable while refusing the resource behind it.
Revalidating a value costs nothing where the second call asks for no more than the first, as validating a resource explains.
The template the shape admits
The value to validate as a retrieval template
Validation options
Readonlyshape: Lazy<ResourceShape>The shape the template is matched against, possibly deferred to break definition cycles
Readonlymodel: trueMust be true to validate value as a template rather than as a resource
Optional Readonlyplain?: booleanWhether to refuse the transforms combining several values into one, leaving a template that retrieves rather than computes
Optional Readonlydepth?: numberThe nesting a template may ask for, counting each resource it descends into; 0 refuses every
nested template while still admitting the identifier naming the resource
Optional Readonlylimit?: numberThe largest page a template may ask for; a collection asking for none is held to it, and one
asking for more is refused. 0, like omitting it, leaves the page to the caller
A Relay carrying the template where it passes and a trace of the violations where it doesn't
TraceError Where shape is malformed
Validates a value against a shape.