npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@gateweb/zod-schema

v1.0.0

Published

Zod schema for GateWeb

Readme

@gateweb/zod-schema

@gateweb/zod-schema,封裝常用表單欄位規則,並內建可與 i18n 翻譯函式整合的錯誤訊息產生方式。

  • 支援:字串、陣列、Email、日期 Timestamp、統一編號、檔案...等常見欄位
  • 友善 i18n:所有錯誤訊息可透過自帶的 TranslateFn 組合
  • 型別安全:以 Zod 為核心,完整 TypeScript 推導
  • 實用工具:提供 extractValidationResultextractObjectValidationResult 便於測時取得錯誤訊息

Installation

# With pnpm (recommended)
pnpm add @gateweb/zod-schema

# With npm
npm install @gateweb/zod-schema

# With yarn
yarn add @gateweb/zod-schema

Usage

Quick start

import { z } from 'zod';
import { createStringSchema } from '@gateweb/zod-schema';
import { useTranslate } from 'your-i18n-lib'; // 假設你有一個 i18n 函式

const t = useTranslate();
const stringSchema = createStringSchema(t);
const nameSchema = stringSchema({ required: true, maxLength: 50, fieldName: '姓名' });
stringSchema.parse('測試名稱'); // 成功
stringSchema.parse(''); // 失敗,拋出錯誤訊息 "

notice: 所有的 schema creator 都需要傳入一個 TranslateFn 函式作為參數。

With i18n

  • 本套件不綁定特定 i18n 套件,只要提供 TranslateFn 簽名 (key: string, options?: any) => string 即可。
  • 你可以將現有的 t() 直接傳入,例如 createStringSchema(t)
  • 未提供 fieldName 時,部分 Schema 會使用預設欄位名稱(如 Email日期 等)。

Type Inference

  • 所有 Schema 皆使用 Zod,支援 z.infer<typeof schema> 自動推導。
  • 範例:
const imageInfo = createImageInfoSchema(t)();
type ImageInfo = z.infer<ReturnType<typeof imageInfo>>; // { image: File | string | null; id: number }

API

詳見 API 文件

Contributing

Contributions are welcome! To ensure a smooth development process, please follow these steps:

  1. Fork & Clone: Fork the repository and clone it to your local machine.

  2. Set Up: This project uses pnpm as the package manager. Install dependencies with:

    pnpm install
  3. Develop: Create a new branch for your feature or bug fix.

  4. Test: Write tests for your changes and ensure all existing tests pass.

    # Run all tests
    pnpm test
    
    # Run tests in watch mode
    pnpm test:watch
  5. Submit a Pull Request: Push your changes to your fork and open a pull request to the main branch. Your code will be automatically linted and formatted upon commit.

Publishing (For Maintainers)

Manual Release

  1. Update the version in package.json.
  2. Install dependencies and build the package:
    pnpm install && pnpm build
  3. Log in to npm:
    pnpm login
  4. Publish the package:
    pnpm publish --access public --no-git-checks

Automatic Release

When a pull request is merged into the main branch, the release GitHub Action will automatically bump the version, create a changelog, and publish the new version to npm. The version bump follows Semantic Versioning based on the commit messages (e.g., feat: for minor, fix: for patch).