UNPKG

zod-valid

Version:

Lightweight utilities for flexible Zod schema validation (string, number, array, object, boolean, ISO).

18 lines (17 loc) 333 B
// src/utils.ts import z from "zod"; function nonNullable(schema, message) { return schema.transform((val, ctx) => { if (val == null) { ctx.addIssue({ code: "custom", message: message ?? "Cannot be null or undefined" }); return z.NEVER; } return val; }); } export { nonNullable };