Const
The schema is registered in the BupkisRegistry
with the name
ObjectWithNullPrototype
for later reference and type checking purposes.
const nullProtoObj = Object.create(null);
nullProtoObj.key = 'value';
NullProtoObjectSchema.parse(nullProtoObj); // ✓ Valid
const regularObj = { key: 'value' };
NullProtoObjectSchema.parse(regularObj); // ✗ Throws validation error
const emptyObj = {};
NullProtoObjectSchema.parse(emptyObj); // ✗ Throws validation error
A Zod schema that validates plain objects with null prototypes.
This schema validates objects that have been created with
Object.create(null)
or otherwise have their prototype set tonull
. Such objects are "plain" objects without any inherited properties or methods fromObject.prototype
, making them useful as pure data containers or dictionaries.