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

@inverz/thai-zod

v1.0.0

Published

Zod schemas for Thai data with Thai error messages: national ID, tax ID, phone, postcode, Thai dates, birth date and baht amounts

Readme

@inverz/thai-zod

Zod schema สำหรับข้อมูลไทย: เลขบัตรประชาชน / เลขผู้เสียภาษี (ตรวจ checksum), เบอร์โทร, รหัสไปรษณีย์, วันที่ไทย, วันเกิด (ตรวจอายุ) และ จำนวนเงิน ข้อความผิดพลาดเป็นภาษาไทย และได้ค่าที่ทำความสะอาดแล้วไปใช้ต่อ ใช้ได้กับ zod 3.23 ขึ้นไปและ zod 4 ไม่มี React

ดูตัวอย่าง (Demo)

Zod schemas for Thai national IDs, tax IDs, phone numbers, postcodes, Thai dates, birth dates and baht amounts, with Thai error messages. Works with zod 3.23+ and zod 4.

ติดตั้ง

npm i @inverz/thai-zod zod
import { z } from "zod";
import { zThaiId, zThaiPhone, zPostcode, zThaiDate, zBirthDate, zBaht } from "@inverz/thai-zod";

const signup = z.object({
  nationalId: zThaiId(),
  phone: zThaiPhone({ mobileOnly: true }),
  birthDate: zBirthDate({ minAge: 18 }),
  postcode: zPostcode(),
  referrer: zThaiPhone({ optional: true, label: "เบอร์ผู้แนะนำ" }),
});

signup.parse({ nationalId: "1-1017-00203-45-0", phone: "081-234-5678", birthDate: "15 มี.ค. 2530", postcode: "10200", referrer: "" });
// { nationalId: "1101700203450", phone: "0812345678", birthDate: Date, postcode: "10200", referrer: undefined }

ใช้กับ react-hook-form ผ่าน zodResolver(signup) ได้ตามปกติ

Schema

| schema | รับ | ได้ | ข้อความเมื่อผิด (ตัวอย่าง) | |---|---|---|---| | zThaiId() | "1-1017-00203-45-0" | "1101700203450" | เลขบัตรประชาชนต้องมี 13 หลัก / เลขบัตรประชาชนไม่ถูกต้อง | | zThaiTaxId() | เลขผู้เสียภาษี 13 หลัก | ตัวเลขล้วน | เลขผู้เสียภาษีไม่ถูกต้อง | | zThaiPhone() | มือถือ บ้าน 1XXX 1800 และ +66 | "0812345678" | เบอร์โทรไม่ถูกต้อง | | zThaiPhone({ mobileOnly: true }) | | | ต้องเป็นเบอร์มือถือ (06, 08, 09) | | zThaiPhone({ output }) | | "digits" / "international" (+66812345678) / "formatted" (081-234-5678) | | | zPostcode() | "10200" หรือ 10200 | "10200" | รหัสไปรษณีย์ต้องเป็นตัวเลข 5 หลัก | | zThaiDate({ min, max }) | Date, timestamp, "27 ก.ย. 2569", "27/09/2569", "2026-09-27" | Date | วันที่ไม่ถูกต้อง / ต้องไม่หลัง 27 ก.ย. 2569 | | zBirthDate({ minAge, maxAge }) | เหมือน zThaiDate | Date | ต้องมีอายุอย่างน้อย 18 ปี | | zBaht({ min, max }) | 1500, "1,500.50", "฿1,500 บาท" | 1500.5 | ทศนิยมได้ไม่เกิน 2 ตำแหน่ง / ต้องไม่เกิน 50,000 บาท |

  • zThaiDate ใช้ "today" เป็น min / max ได้ และเทียบเป็นวัน ไม่สนเวลา
  • ปี พ.ศ. แปลงเป็น ค.ศ. ให้เอง (อ่านวันที่ด้วย parseThaiDate ของ @inverz/thai-date)

ตัวเลือกที่ใช้ได้กับทุก schema

| ตัวเลือก | คำอธิบาย | |---|---| | optional: true | ค่าว่าง ("", null, undefined) ผ่านเป็น undefined ฟอร์มส่ง "" มาเมื่อไม่กรอก จึงใช้ .optional() ของ zod อย่างเดียวไม่พอ | | label | ชื่อช่องในข้อความ เช่น label: "เลขบัตรผู้ปกครอง" → "กรุณากรอกเลขบัตรผู้ปกครอง" | | message | ข้อความเดียวแทนข้อความทั้งหมดของ schema นั้น | | locale: "en" | ข้อความภาษาอังกฤษ |

ตั้งภาษาทั้งแอปด้วย setThaiZodLocale("en") (มีผลกับ schema ที่สร้างหลังเรียก)

TypeScript

type Signup = z.infer<typeof signup>;
// { nationalId: string; phone: string; birthDate: Date; postcode: string; referrer: string | undefined }

หมายเหตุ

ฟังก์ชันตรวจเลขบัตรและเบอร์โทรมาจาก @inverz/thai-input ถูกรวมไว้ในแพ็กเกจตอน build ติดตั้งแพ็กเกจนี้จึงไม่ดึง React มาด้วย

License

MIT © 2026 Inverz Solutions Co.,Ltd.