Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/better chinese translate #2988

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<h1 align="center">Zod</h1>
<p align="center">TypeScript-first schema validation with static type inference
<br/>
<a href="https://zod.dev">https://zod.dev</a></p>
<a href="https://zod.dev">https://zod.dev</a>
</p>
<br/>
<p align="center">
Expand Down Expand Up @@ -35,14 +35,14 @@

# 內容

- [什么是 Zod](#什么是Zod)
- [什么是 Zod](#什么是 Zod)
- [生态体系](#生态系统)
- [安装](#安装)
- [基本用法](#基本用法)
- [定义模式](#定义模式)
- [基本原理](#基本原理)
- [字面意义](#字面意义)
- [Strings](#strings)
- [原始值类型(primitive)](#原始值类型(primitive))
- [字面量(literal)](#字面量(literal))
- [字符串](#字符串)
- [Numbers](#numbers)
- [Objects](#objects)
- [.shape](#shape)
Expand Down Expand Up @@ -375,47 +375,48 @@ type User = z.infer<typeof User>;

# 定义模式

## 基本原理
## 原始值类型(primitive)

```ts
import { z } from "zod";

// 原始值
// 原始值类型
z.string();
z.number();
z.bigint();
z.boolean();
z.date();
z.symbol();

// 空类型
z.undefined();
z.null();
z.void(); // 接受null或undefined
z.void(); // 接受 undefined

// 全能类型
// 允许 any value
// 任意类型
// 允许任意类型的值
z.any();
z.unknown();

// never 类型
// 允许没有 values
// 不允许值类型存在
z.never();
```

## 字面意义
## 字面量(literal)

```ts
const tuna = z.literal("tuna");
const twelve = z.literal(12);
const tru = z.literal(true);

// 检索字面意义的值
// 检索字面量的值
tuna.value; // "tuna"
```

> 目前在 Zod 中不支持 Date 或 bigint 字面。如果你有这个功能的用例,请提交一个 Issue。
## Strings
## 字符串

Zod 包括一些针对字符串的验证。

Expand Down