API reference › @evolu/common › Type › Object

const Object: createRootType(
  "Object",
  (
    value: unknown,
    options: ValidationOptions = firstValidationOptions,
  ): Result<Readonly<Record<string, unknown>>, PlainObjectError> => {
    const error = checkPlainObject(value, options);
    return error === undefined
      ? ok(value as Readonly<Record<string, unknown>>)
      : err(error);
  },
  formatObjectError,
  {
    getTypeIssues: createObjectRuntimeTypeIssues(),
    check: checkPlainObject,
  },
);

Defined in: packages/common/src/Type.ts:15547

A Type for readonly plain objects with unknown property values.

Object is the runtime counterpart of a Readonly<Record<string, unknown>> data boundary. Its prototype rule uses the realm-neutral structural heuristic described by isPlainObject. A matching custom root prototype can be classified as plain; other custom prototypes and class instances are rejected. Every own property must have a string key and be an enumerable data property. Accessors, non-enumerable properties, and symbol properties are rejected without reading their values.

Use object when property names are fixed, record when keys and values have their own Types, and instanceOf when an instance belongs to the domain.