Track and save on groceries
1import z from "zod/v4";
2
3export class SchemaNoTitleError extends Error {
4 constructor() {
5 super(`Schema has no title metadata`);
6 }
7}
8
9export const schemaTitle = (schema: z.ZodType) => {
10 const meta = schema.meta();
11 if (!meta?.title) {
12 throw new SchemaNoTitleError();
13 }
14 return meta.title;
15};