@sifat046/zod-bhasha
v0.2.0
Published
Zod error messages with i18n (EN + BN out of the box).
Downloads
6
Maintainers
Readme
🌐 zod-bhasha
Multilingual error messages for Zod — starting with English 🇬🇧 and Bangla 🇧🇩. Keep your validation errors human-friendly, localized, and developer-friendly ✨
📦 Installation
Using npm:
npm install zod-bhashaUsing yarn:
yarn add zod-bhashaUsing pnpm:
pnpm add zod-bhasha🚀 Usage
1. Import and set locale globally
import { z } from "zod";
import { withBhasha, setLocale } from "zod-bhasha";
// Enable zod-bhasha
withBhasha(z);
// Set Bangla as default locale
setLocale("bn");
const schema = z.string().min(5);
console.log(schema.safeParse("hi").error?.format());
// Output (Bangla): "কমপক্ষে ৫ অক্ষর হতে হবে"2. Override locale per validation
import { z } from "zod";
import { withBhasha } from "zod-bhasha";
withBhasha(z);
const schema = z.string().email();
console.log(schema.safeParse("invalid", { locale: "en" }).error?.format());
// Output: "Invalid email address"
console.log(schema.safeParse("invalid", { locale: "bn" }).error?.format());
// Output: "ইমেইল ঠিকানা সঠিক নয়"🌍 Supported Locales
- 🇬🇧 English (
en) - 🇧🇩 Bangla (
bn)
🔜 More languages coming soon! Contributions welcome 🎉
🛠️ Contributing
- Fork the repo 🍴
- Create a feature branch 🌱
- Add your locale / improvements
- Submit a PR 🚀
📜 License
MIT © 2025 — Made with ❤️ by [Md Sifat Bin Jibon] Github repo:- https://github.com/Md-Sifat-code/zod-bhasha
