import { z } from 'zod'; export class AssertConstrained> { itemSchema: z.ZodSchema; constructor(itemSchema: z.ZodSchema) { this.itemSchema = itemSchema; } check(item: unknown): item is T { return this.itemSchema.safeParse(item).success; } checkArray(arr: unknown[]): arr is T[] { return this.itemSchema.array().safeParse(arr).success; } }