Constclass MyClass {}
function MyConstructor() {}
ConstructibleSchema.parse(MyClass); // ✓ Valid
ConstructibleSchema.parse(MyConstructor); // ✓ Valid
ConstructibleSchema.parse(Array); // ✓ Valid
ConstructibleSchema.parse(Date); // ✓ Valid
ConstructibleSchema.parse(() => {}); // ✗ Throws validation error
ConstructibleSchema.parse({}); // ✗ Throws validation error
import { createAssertion, use } from 'bupkis';
import { ConstructibleSchema } from 'bupkis/schema';
const classAssertion = createAssertion(
  [ConstructibleSchema, 'to be a subclass of Error'],
  ConstructibleSchema.refine(
    (subject) => subject.prototype instanceof Error,
  ),
);
const { expect } = use([classAssertion]);
expect(class MyError extends Error {}, 'to be a subclass of Error');
A Zod schema that validates JavaScript constructible functions.
This schema validates values that can be used as constructors, including ES6 classes, traditional constructor functions, and built-in constructors. It uses the isConstructible guard function to determine if a value can be invoked with the
newoperator to create object instances.