Whether value matches type — shared by both decode
(validator.cjs's materialize) and encode-time validation
(validateForEncode): the same recursive check, the same function,
for both directions.
{form: 'reference', name} checks the originating schema's name,
not the value's own shape — which is how it correctly rejects a
materialized value that satisfies its own schema but is the wrong
one for this field. Three sources carry that name: an opaque,
unregistered DXNStruct carries its own wire name directly; a
value that went through a registered schema (decode or
encode-time validation alike) carries it via Validated; the
third, encode-only source: registry (null for decode, which
never needs it) lets a real, unwrapped application class
instance's own constructor be checked against whatever class was
registered for name — needed only for a value that turned out to
have no schema of its own to be wrapped by.
Whether
valuematchestype— shared by both decode (validator.cjs'smaterialize) and encode-time validation (validateForEncode): the same recursive check, the same function, for both directions.{form: 'reference', name}checks the originating schema's name, not the value's own shape — which is how it correctly rejects a materialized value that satisfies its own schema but is the wrong one for this field. Three sources carry that name: an opaque, unregisteredDXNStructcarries its own wire name directly; a value that went through a registered schema (decode or encode-time validation alike) carries it viaValidated; the third, encode-only source:registry(nullfor decode, which never needs it) lets a real, unwrapped application class instance's own constructor be checked against whatever class was registered forname— needed only for a value that turned out to have no schema of its own to be wrapped by.