zod-zz
v0.0.5
Published
zod-zz has a bunch of extra types for zod (requires zod as peer dependency)
Maintainers
Readme
zod-zz
One zod-extend package to rule them all, one zod-extend package to find them, One zod-extend package to package them all and in the darkness bind them.
A Zod extension package that provides additional schema types and methods for enhanced validation.
npm install zod zod-zzimport { z } from 'zod';
import { extendZod } from 'zod-zz';
const zz = extendZod(z);
zz.string(); // existing zod functions
zz.currency(); // extended set of zod functionsAvailable Extensions
Currency
Validates ISO 4217 currency codes:
import { z } from 'zod';
import { extendZod } from 'zod-zz';
const extendedZod = extendZod(z);
const currencySchema = extendedZod.currency();
// Valid currencies
currencySchema.parse('USD'); // ✅
currencySchema.parse('EUR'); // ✅
currencySchema.parse('GBP'); // ✅
currencySchema.parse('usd'); // ✅ (case-insensitive)
// Invalid currencies
currencySchema.parse('INVALID'); // ❌ Throws error
currencySchema.parse(''); // ❌ Throws errorAPI Reference
extendZod(zod: typeof z): typeof z
Extends a Zod instance with additional schema types and methods.
Parameters:
zod: The Zod instance to extend
Returns:
- The extended Zod instance with additional methods
Development
# Install dependencies
npm install
# Build the package
npm run build
# Run tests
npm test
# Run tests in watch mode
npm run test:watchLicense
MIT
