ConstWrappedPromiseLikeSchema.parse(Promise.resolve(42)); // ✓ Valid (returns Promise)
WrappedPromiseLikeSchema.parse({ then: () => {} }); // ✓ Valid (thenable)
WrappedPromiseLikeSchema.parse(42); // ✗ Throws validation error
WrappedPromiseLikeSchema.parse({}); // ✗ Throws validation error
import { createAssertion, use } from 'bupkis';
import { WrappedPromiseLikeSchema } from 'bupkis/schema';
const thenableAssertion = createAssertion(
  [WrappedPromiseLikeSchema, 'to be a thenable'],
  WrappedPromiseLikeSchema,
);
const { expect } = use([thenableAssertion]);
// does nothing with 'pants'; await it elsewhere
expect({ then: () => Promise.resolve('pants') }, 'to be a thenable');
A Zod schema that validates "thenable" objects with a
.then()method.This schema validates objects that implement the PromiseLike interface by having a
.then()method, which includes Promises and other thenable objects.Unlike Zod's built-in
z.promise(), this schema does not unwrap the resolved value, meaning the result of parsing remains a Promise or thenable object.