hasNonStrictObjectRoot
hasNonStrictObjectRoot(
schema):boolean
Defined in: packages/contracts/src/event-stream.ts:194
Whether an Event stream’s payload schema has a NON-strict object at its root — the one shape
validateEventStreams refuses (ADR-0053 decision 1: the payload contract is strict, and the promise is
enforced rather than advertised).
zod v4 models strictness as the object’s catchall: .strict() / z.strictObject() set it to
ZodNever, a bare z.object() leaves it unset (unknown keys are silently STRIPPED), and
z.looseObject() / .catchall(…) set something else. So the rule is exactly “an object root’s catchall
must be never”, read off _zod.def — the same duck-typed posture as isZodSchema, never an
instanceof a peer-installed class.
A union (or discriminated union) is walked recursively, because each member is equally a root the client
may append against. Every other root — string, array, record, a .transform() pipeline — is NOT an
object and is accepted unchanged. A schema whose internals cannot be read at all (a duplicated zod
install, a hand-rolled duck-typed schema) is likewise accepted: this check can only refuse what it can
actually see.
Parameters
Section titled “Parameters”schema
Section titled “schema”unknown
Returns
Section titled “Returns”boolean