@express-zod-api/zod-plugin
v5.0.0
Published
Zod plugin for express-zod-api
Maintainers
Readme
Zod Plugin for Express Zod API
Overview
This module extends Zod functionality when it's imported:
- Adds
.example()method to all Zod schemas:- shorthand for
.meta({ examples: [...] });
- shorthand for
- Adds
.deprecated()method to all Zod schemas:- shorthand for
.meta({ deprecated: true });
- shorthand for
- Adds
.xBrand()method to all Zod schemas:- shorthand for
.meta({ "x-brand": ... })making the brand available in runtime; - This method does not conflict with Zod 4.4+ internal mechanisms;
- shorthand for
- Adds
.label()method toZodDefault:- shorthand for
.meta({ default: ... });
- shorthand for
- Adds
.remap()method toZodObjectfor renaming object properties:- Supports a mapping object or an object transforming function as an argument;
- Relies on
R.renameKeys()from theramdalibrary;
Requirements
- Compatible with Zod versions
^4.3.4(including 4.4+);
Basic usage
import { z } from "zod";
import "@express-zod-api/zod-plugin";
const schema = z.string().example("test").example("another").xBrand("custom");
schema.meta(); // { examples: ["test", "another"], "x-brand": "custom" }