@kaeawc/auto-mobile 0.0.91 → 0.0.92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build-info.json +12 -12
- package/dist/schemas/README.md +16 -0
- package/dist/schemas/prototype-icon-names.json +302 -0
- package/dist/src/chunk-09442h7v.js +4 -0
- package/dist/src/chunk-0dfnyfkh.js +5 -0
- package/dist/src/chunk-0e4gm1kj.js +5 -0
- package/dist/src/chunk-0eb8576f.js +4 -0
- package/dist/src/chunk-0rjm4nx7.js +5 -0
- package/dist/src/chunk-0w1spptt.js +6 -0
- package/dist/src/chunk-1zmh2eak.js +4 -0
- package/dist/src/chunk-28k63ha3.js +5 -0
- package/dist/src/chunk-2d4wmp8b.js +4 -0
- package/dist/src/chunk-2e6s75qv.js +78 -0
- package/dist/src/chunk-2v7tw1nj.js +5 -0
- package/dist/src/chunk-32jpxz2y.js +323 -0
- package/dist/src/chunk-34zxqcmq.js +5 -0
- package/dist/src/chunk-3jmvqygr.js +238 -0
- package/dist/src/chunk-3swvfhqt.js +5 -0
- package/dist/src/chunk-44bt78m9.js +5 -0
- package/dist/src/chunk-488vt2bp.js +4 -0
- package/dist/src/chunk-4fgdhcwx.js +5 -0
- package/dist/src/chunk-4jp2se4w.js +4 -0
- package/dist/src/chunk-4pfftt07.js +5 -0
- package/dist/src/chunk-4vhr9e4t.js +4 -0
- package/dist/src/chunk-4xd6zs3y.js +15 -0
- package/dist/src/chunk-51567pg8.js +4 -0
- package/dist/src/chunk-5agqsfev.js +4 -0
- package/dist/src/chunk-5d706gmr.js +4 -0
- package/dist/src/chunk-5kd4rqk7.js +5 -0
- package/dist/src/chunk-5s645vr4.js +4 -0
- package/dist/src/chunk-61t538bm.js +4 -0
- package/dist/src/chunk-6d3mmqxt.js +54 -0
- package/dist/src/chunk-6hyt398x.js +5 -0
- package/dist/src/chunk-6mnr8kpm.js +4 -0
- package/dist/src/chunk-6pg7bqck.js +4 -0
- package/dist/src/chunk-79q5xsdc.js +42 -0
- package/dist/src/chunk-7bdgand3.js +4 -0
- package/dist/src/chunk-84cp9dw5.js +4 -0
- package/dist/src/chunk-86f2h5ww.js +5 -0
- package/dist/src/chunk-8cghfzb2.js +19 -0
- package/dist/src/chunk-8en08r7q.js +5 -0
- package/dist/src/chunk-950qcq1e.js +10 -0
- package/dist/src/chunk-9rkfyt6q.js +5 -0
- package/dist/src/chunk-9tf2p9y9.js +5 -0
- package/dist/src/chunk-9y5bcy28.js +6 -0
- package/dist/src/chunk-a2sc4jm0.js +5 -0
- package/dist/src/chunk-a4k9rt7z.js +5 -0
- package/dist/src/chunk-aa5ng3d1.js +4 -0
- package/dist/src/chunk-ajsrz473.js +5 -0
- package/dist/src/chunk-b3h0a6ca.js +4 -0
- package/dist/src/chunk-b4cxdzwy.js +20 -0
- package/dist/src/chunk-b6a737qt.js +4 -0
- package/dist/src/chunk-bn64x5z5.js +5 -0
- package/dist/src/chunk-bvh649za.js +12 -0
- package/dist/src/chunk-c9nk1r78.js +5 -0
- package/dist/src/chunk-c9tyfg4j.js +26 -0
- package/dist/src/chunk-cfsdfqnm.js +4 -0
- package/dist/src/chunk-cxyf04jc.js +7 -0
- package/dist/src/chunk-d57432wq.js +4 -0
- package/dist/src/chunk-da08tx5v.js +4 -0
- package/dist/src/chunk-eka89q3k.js +4 -0
- package/dist/src/chunk-f2tc08m2.js +4 -0
- package/dist/src/chunk-f8tnk179.js +5 -0
- package/dist/src/chunk-f9s1kkhx.js +5 -0
- package/dist/src/chunk-fbp8a4rx.js +4 -0
- package/dist/src/chunk-fd2z0sze.js +4 -0
- package/dist/src/chunk-fk927f4q.js +54 -0
- package/dist/src/chunk-fxmr3a0f.js +4 -0
- package/dist/src/chunk-gaqwhd44.js +4 -0
- package/dist/src/chunk-ggtd5x5a.js +5 -0
- package/dist/src/chunk-gndcfrm7.js +4 -0
- package/dist/src/chunk-h3n4adc6.js +310 -0
- package/dist/src/chunk-h5pjbb83.js +4 -0
- package/dist/src/chunk-hgnnh302.js +4 -0
- package/dist/src/chunk-hmke8nhx.js +5 -0
- package/dist/src/chunk-j2bx12hn.js +4 -0
- package/dist/src/chunk-j70y1a2g.js +4 -0
- package/dist/src/chunk-jdqvcq0a.js +5 -0
- package/dist/src/chunk-jhnbfj19.js +55 -0
- package/dist/src/chunk-js1jpyxp.js +6 -0
- package/dist/src/chunk-kbjq0qvb.js +4 -0
- package/dist/src/chunk-kfwx57xd.js +4 -0
- package/dist/src/chunk-km0dy5vc.js +71 -0
- package/dist/src/chunk-kzwctna2.js +4 -0
- package/dist/src/chunk-m9ehyehy.js +4 -0
- package/dist/src/chunk-mct91p1f.js +4 -0
- package/dist/src/chunk-mf9spd4g.js +5 -0
- package/dist/src/chunk-mgrcansb.js +4 -0
- package/dist/src/chunk-mqc1d0eb.js +6 -0
- package/dist/src/chunk-n1zmpk0z.js +4 -0
- package/dist/src/chunk-ncyjf63g.js +4 -0
- package/dist/src/chunk-nr64d21q.js +973 -0
- package/dist/src/chunk-nwm2pq5v.js +168 -0
- package/dist/src/chunk-pm06b05d.js +9 -0
- package/dist/src/chunk-q50s00ry.js +4 -0
- package/dist/src/chunk-qv2918jt.js +4 -0
- package/dist/src/chunk-qwye1958.js +14 -0
- package/dist/src/chunk-r0f1q783.js +5 -0
- package/dist/src/chunk-r14wwk37.js +18 -0
- package/dist/src/chunk-r20pe1nv.js +5 -0
- package/dist/src/chunk-r8z9pfve.js +5 -0
- package/dist/src/chunk-rdpgkjf6.js +4 -0
- package/dist/src/chunk-rkr0dks9.js +5 -0
- package/dist/src/chunk-rn84t3sf.js +11 -0
- package/dist/src/chunk-s123kn7n.js +4 -0
- package/dist/src/chunk-s1zq65ny.js +4 -0
- package/dist/src/chunk-s73qn3fx.js +4 -0
- package/dist/src/chunk-sjn0nj4p.js +5 -0
- package/dist/src/chunk-sns0c35v.js +7 -0
- package/dist/src/chunk-stfzjr9y.js +8 -0
- package/dist/src/chunk-sz1a7p43.js +4 -0
- package/dist/src/chunk-t4dr5c8v.js +8 -0
- package/dist/src/chunk-tc8k9c1j.js +4 -0
- package/dist/src/chunk-teznhase.js +4 -0
- package/dist/src/chunk-ty9xgmz4.js +4 -0
- package/dist/src/chunk-tyazf3sk.js +145 -0
- package/dist/src/chunk-v6npjrjm.js +5 -0
- package/dist/src/chunk-v90es00d.js +4 -0
- package/dist/src/chunk-vbvtzkwz.js +5 -0
- package/dist/src/chunk-vefd8qee.js +8 -0
- package/dist/src/chunk-vs9r72ta.js +17 -0
- package/dist/src/chunk-w2mwa0jk.js +4 -0
- package/dist/src/chunk-w7zsh13a.js +9 -0
- package/dist/src/chunk-w88k0bgr.js +4 -0
- package/dist/src/chunk-wry6skrm.js +4 -0
- package/dist/src/chunk-wzdt0enk.js +4 -0
- package/dist/src/chunk-xhhv854c.js +4 -0
- package/dist/src/chunk-y58270hd.js +4 -0
- package/dist/src/chunk-yk0hmbex.js +4 -0
- package/dist/src/chunk-ympy4fdz.js +28 -0
- package/dist/src/chunk-yw436axy.js +4 -0
- package/dist/src/chunk-z04jrpjy.js +5 -0
- package/dist/src/chunk-z2xznczw.js +4 -0
- package/dist/src/chunk-z4xnrgps.js +4 -0
- package/dist/src/chunk-z7csyszv.js +4 -0
- package/dist/src/chunk-z8t0v07j.js +11 -0
- package/dist/src/chunk-z916af47.js +228 -0
- package/dist/src/chunk-zcr8he8q.js +5 -0
- package/dist/src/chunk-zd9vmkzn.js +9 -0
- package/dist/src/chunk-zg67wjkh.js +5 -0
- package/dist/src/chunk-zj939v0h.js +5 -0
- package/dist/src/chunk-zkdjwtc1.js +4 -0
- package/dist/src/chunk-zkv5kzt6.js +4 -0
- package/dist/src/daemon/processEntry.js +4 -0
- package/dist/src/index.js +4 -2843
- package/dist/src/runtime/bunRuntimeGuard.js +4 -0
- package/dist/src/utils/workers/iosBundleExtractWorker.js +2 -3
- package/package.json +5 -5
- package/schemas/README.md +16 -0
- package/schemas/prototype-icon-names.json +302 -0
- package/node_modules/@borewit/text-codec/README.md +0 -87
- package/node_modules/@jimp/diff/node_modules/pixelmatch/README.md +0 -110
- package/node_modules/@jimp/diff/node_modules/pixelmatch/node_modules/pngjs/README.md +0 -433
- package/node_modules/@jimp/file-ops/dist/browser/index.js +0 -8
- package/node_modules/@jimp/js-png/README.md +0 -35
- package/node_modules/@jimp/js-png/src/__image_snapshots__/index-node-test-ts-png-should-use-png-options-1-snap.png +0 -0
- package/node_modules/@jimp/js-png/src/output.png +0 -0
- package/node_modules/@jimp/js-png/vitest.config.browser.mjs +0 -3
- package/node_modules/@jimp/plugin-resize/README.md +0 -12
- package/node_modules/@jimp/plugin-resize/vitest.config.browser.mjs +0 -3
- package/node_modules/@tokenizer/inflate/README.md +0 -114
- package/node_modules/@tokenizer/token/README.md +0 -19
- package/node_modules/await-to-js/README.md +0 -82
- package/node_modules/debug/README.md +0 -481
- package/node_modules/exif-parser/README.md +0 -83
- package/node_modules/file-type/readme.md +0 -667
- package/node_modules/ieee754/README.md +0 -51
- package/node_modules/mime/README.md +0 -178
- package/node_modules/ms/readme.md +0 -59
- package/node_modules/parse-bmfont-xml/README.md +0 -74
- package/node_modules/parse-bmfont-xml/lib/browser.js +0 -85
- package/node_modules/parse-bmfont-xml/node_modules/xml2js/README.md +0 -507
- package/node_modules/pngjs/README.md +0 -287
- package/node_modules/sax/README.md +0 -228
- package/node_modules/strtok3/README.md +0 -795
- package/node_modules/tinycolor2/README.md +0 -492
- package/node_modules/tinycolor2/cjs/test.js +0 -2191
- package/node_modules/tinycolor2/cjs/test_template.js +0 -26
- package/node_modules/tinycolor2/deno_asserts@0.168.0.mjs +0 -807
- package/node_modules/tinycolor2/esm/test.js +0 -2189
- package/node_modules/tinycolor2/esm/test_template.js +0 -24
- package/node_modules/tinycolor2/tinycolor.js +0 -1191
- package/node_modules/token-types/README.md +0 -160
- package/node_modules/uint8array-extras/readme.md +0 -318
- package/node_modules/xml-parse-from-string/README.md +0 -35
- package/node_modules/xmlbuilder/README.md +0 -86
- package/node_modules/zod/README.md +0 -208
- package/node_modules/zod/v4/locales/ar.d.cts +0 -4
- package/node_modules/zod/v4/locales/ar.d.ts +0 -4
- package/node_modules/zod/v4/locales/az.d.cts +0 -4
- package/node_modules/zod/v4/locales/az.d.ts +0 -4
- package/node_modules/zod/v4/locales/be.d.cts +0 -4
- package/node_modules/zod/v4/locales/be.d.ts +0 -4
- package/node_modules/zod/v4/locales/ca.d.cts +0 -4
- package/node_modules/zod/v4/locales/ca.d.ts +0 -4
- package/node_modules/zod/v4/locales/cs.d.cts +0 -4
- package/node_modules/zod/v4/locales/cs.d.ts +0 -4
- package/node_modules/zod/v4/locales/de.d.cts +0 -4
- package/node_modules/zod/v4/locales/de.d.ts +0 -4
- package/node_modules/zod/v4/locales/en.d.cts +0 -5
- package/node_modules/zod/v4/locales/en.d.ts +0 -5
- package/node_modules/zod/v4/locales/eo.d.cts +0 -5
- package/node_modules/zod/v4/locales/eo.d.ts +0 -5
- package/node_modules/zod/v4/locales/es.d.cts +0 -4
- package/node_modules/zod/v4/locales/es.d.ts +0 -4
- package/node_modules/zod/v4/locales/fa.d.cts +0 -4
- package/node_modules/zod/v4/locales/fa.d.ts +0 -4
- package/node_modules/zod/v4/locales/fi.d.cts +0 -4
- package/node_modules/zod/v4/locales/fi.d.ts +0 -4
- package/node_modules/zod/v4/locales/fr-CA.d.cts +0 -4
- package/node_modules/zod/v4/locales/fr-CA.d.ts +0 -4
- package/node_modules/zod/v4/locales/fr.d.cts +0 -4
- package/node_modules/zod/v4/locales/fr.d.ts +0 -4
- package/node_modules/zod/v4/locales/he.d.cts +0 -4
- package/node_modules/zod/v4/locales/he.d.ts +0 -4
- package/node_modules/zod/v4/locales/hu.d.cts +0 -4
- package/node_modules/zod/v4/locales/hu.d.ts +0 -4
- package/node_modules/zod/v4/locales/id.d.cts +0 -4
- package/node_modules/zod/v4/locales/id.d.ts +0 -4
- package/node_modules/zod/v4/locales/index.d.cts +0 -39
- package/node_modules/zod/v4/locales/index.d.ts +0 -39
- package/node_modules/zod/v4/locales/it.d.cts +0 -4
- package/node_modules/zod/v4/locales/it.d.ts +0 -4
- package/node_modules/zod/v4/locales/ja.d.cts +0 -4
- package/node_modules/zod/v4/locales/ja.d.ts +0 -4
- package/node_modules/zod/v4/locales/kh.d.cts +0 -4
- package/node_modules/zod/v4/locales/kh.d.ts +0 -4
- package/node_modules/zod/v4/locales/ko.d.cts +0 -4
- package/node_modules/zod/v4/locales/ko.d.ts +0 -4
- package/node_modules/zod/v4/locales/mk.d.cts +0 -4
- package/node_modules/zod/v4/locales/mk.d.ts +0 -4
- package/node_modules/zod/v4/locales/ms.d.cts +0 -4
- package/node_modules/zod/v4/locales/ms.d.ts +0 -4
- package/node_modules/zod/v4/locales/nl.d.cts +0 -4
- package/node_modules/zod/v4/locales/nl.d.ts +0 -4
- package/node_modules/zod/v4/locales/no.d.cts +0 -4
- package/node_modules/zod/v4/locales/no.d.ts +0 -4
- package/node_modules/zod/v4/locales/ota.d.cts +0 -4
- package/node_modules/zod/v4/locales/ota.d.ts +0 -4
- package/node_modules/zod/v4/locales/pl.d.cts +0 -4
- package/node_modules/zod/v4/locales/pl.d.ts +0 -4
- package/node_modules/zod/v4/locales/ps.d.cts +0 -4
- package/node_modules/zod/v4/locales/ps.d.ts +0 -4
- package/node_modules/zod/v4/locales/pt.d.cts +0 -4
- package/node_modules/zod/v4/locales/pt.d.ts +0 -4
- package/node_modules/zod/v4/locales/ru.d.cts +0 -4
- package/node_modules/zod/v4/locales/ru.d.ts +0 -4
- package/node_modules/zod/v4/locales/sl.d.cts +0 -4
- package/node_modules/zod/v4/locales/sl.d.ts +0 -4
- package/node_modules/zod/v4/locales/sv.d.cts +0 -4
- package/node_modules/zod/v4/locales/sv.d.ts +0 -4
- package/node_modules/zod/v4/locales/ta.d.cts +0 -4
- package/node_modules/zod/v4/locales/ta.d.ts +0 -4
- package/node_modules/zod/v4/locales/th.d.cts +0 -4
- package/node_modules/zod/v4/locales/th.d.ts +0 -4
- package/node_modules/zod/v4/locales/tr.d.cts +0 -5
- package/node_modules/zod/v4/locales/tr.d.ts +0 -5
- package/node_modules/zod/v4/locales/ua.d.cts +0 -4
- package/node_modules/zod/v4/locales/ua.d.ts +0 -4
- package/node_modules/zod/v4/locales/ur.d.cts +0 -4
- package/node_modules/zod/v4/locales/ur.d.ts +0 -4
- package/node_modules/zod/v4/locales/vi.d.cts +0 -4
- package/node_modules/zod/v4/locales/vi.d.ts +0 -4
- package/node_modules/zod/v4/locales/zh-CN.d.cts +0 -4
- package/node_modules/zod/v4/locales/zh-CN.d.ts +0 -4
- package/node_modules/zod/v4/locales/zh-TW.d.cts +0 -4
- package/node_modules/zod/v4/locales/zh-TW.d.ts +0 -4
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
<p align="center">
|
|
2
|
-
<img src="logo.svg" width="200px" align="center" alt="Zod logo" />
|
|
3
|
-
<h1 align="center">Zod</h1>
|
|
4
|
-
<p align="center">
|
|
5
|
-
TypeScript-first schema validation with static type inference
|
|
6
|
-
<br/>
|
|
7
|
-
by <a href="https://x.com/colinhacks">@colinhacks</a>
|
|
8
|
-
</p>
|
|
9
|
-
</p>
|
|
10
|
-
<br/>
|
|
11
|
-
|
|
12
|
-
<p align="center">
|
|
13
|
-
<a href="https://github.com/colinhacks/zod/actions?query=branch%3Amaster"><img src="https://github.com/colinhacks/zod/actions/workflows/test.yml/badge.svg?event=push&branch=master" alt="Zod CI status" /></a>
|
|
14
|
-
<a href="https://opensource.org/licenses/MIT" rel="nofollow"><img src="https://img.shields.io/github/license/colinhacks/zod" alt="License"></a>
|
|
15
|
-
<a href="https://www.npmjs.com/package/zod" rel="nofollow"><img src="https://img.shields.io/npm/dw/zod.svg" alt="npm"></a>
|
|
16
|
-
<a href="https://discord.gg/KaSRdyX2vc" rel="nofollow"><img src="https://img.shields.io/discord/893487829802418277?label=Discord&logo=discord&logoColor=white" alt="discord server"></a>
|
|
17
|
-
<a href="https://github.com/colinhacks/zod" rel="nofollow"><img src="https://img.shields.io/github/stars/colinhacks/zod" alt="stars"></a>
|
|
18
|
-
</p>
|
|
19
|
-
|
|
20
|
-
<div align="center">
|
|
21
|
-
<a href="https://zod.dev/api">Docs</a>
|
|
22
|
-
<span> • </span>
|
|
23
|
-
<a href="https://discord.gg/RcG33DQJdf">Discord</a>
|
|
24
|
-
<span> • </span>
|
|
25
|
-
<a href="https://twitter.com/colinhacks">𝕏</a>
|
|
26
|
-
<span> • </span>
|
|
27
|
-
<a href="https://bsky.app/profile/zod.dev">Bluesky</a>
|
|
28
|
-
<br />
|
|
29
|
-
</div>
|
|
30
|
-
|
|
31
|
-
<br/>
|
|
32
|
-
<br/>
|
|
33
|
-
|
|
34
|
-
<h2 align="center">Featured sponsor: Jazz</h2>
|
|
35
|
-
|
|
36
|
-
<div align="center">
|
|
37
|
-
<a href="https://jazz.tools/?utm_source=zod">
|
|
38
|
-
<picture width="85%" >
|
|
39
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/garden-co/jazz/938f6767e46cdfded60e50d99bf3b533f4809c68/homepage/homepage/public/Zod%20sponsor%20message.png">
|
|
40
|
-
<img alt="jazz logo" src="https://raw.githubusercontent.com/garden-co/jazz/938f6767e46cdfded60e50d99bf3b533f4809c68/homepage/homepage/public/Zod%20sponsor%20message.png" width="85%">
|
|
41
|
-
</picture>
|
|
42
|
-
</a>
|
|
43
|
-
<br/>
|
|
44
|
-
<p><sub>Learn more about <a target="_blank" rel="noopener noreferrer" href="mailto:sponsorship@colinhacks.com">featured sponsorships</a></sub></p>
|
|
45
|
-
</div>
|
|
46
|
-
|
|
47
|
-
<br/>
|
|
48
|
-
<br/>
|
|
49
|
-
<br/>
|
|
50
|
-
|
|
51
|
-
### [Read the docs →](https://zod.dev/api)
|
|
52
|
-
|
|
53
|
-
<br/>
|
|
54
|
-
<br/>
|
|
55
|
-
|
|
56
|
-
## What is Zod?
|
|
57
|
-
|
|
58
|
-
Zod is a TypeScript-first validation library. Define a schema and parse some data with it. You'll get back a strongly typed, validated result.
|
|
59
|
-
|
|
60
|
-
```ts
|
|
61
|
-
import * as z from "zod/v4";
|
|
62
|
-
|
|
63
|
-
const User = z.object({
|
|
64
|
-
name: z.string(),
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
// some untrusted data...
|
|
68
|
-
const input = {
|
|
69
|
-
/* stuff */
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
// the parsed result is validated and type safe!
|
|
73
|
-
const data = User.parse(input);
|
|
74
|
-
|
|
75
|
-
// so you can use it with confidence :)
|
|
76
|
-
console.log(data.name);
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
<br/>
|
|
80
|
-
|
|
81
|
-
## Features
|
|
82
|
-
|
|
83
|
-
- Zero external dependencies
|
|
84
|
-
- Works in Node.js and all modern browsers
|
|
85
|
-
- Tiny: `2kb` core bundle (gzipped)
|
|
86
|
-
- Immutable API: methods return a new instance
|
|
87
|
-
- Concise interface
|
|
88
|
-
- Works with TypeScript and plain JS
|
|
89
|
-
- Built-in JSON Schema conversion
|
|
90
|
-
- Extensive ecosystem
|
|
91
|
-
|
|
92
|
-
<br/>
|
|
93
|
-
|
|
94
|
-
## Installation
|
|
95
|
-
|
|
96
|
-
```sh
|
|
97
|
-
npm install zod
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
<br/>
|
|
101
|
-
|
|
102
|
-
## Basic usage
|
|
103
|
-
|
|
104
|
-
Before you can do anything else, you need to define a schema. For the purposes of this guide, we'll use a simple object schema.
|
|
105
|
-
|
|
106
|
-
```ts
|
|
107
|
-
import * as z from "zod/v4";
|
|
108
|
-
|
|
109
|
-
const Player = z.object({
|
|
110
|
-
username: z.string(),
|
|
111
|
-
xp: z.number(),
|
|
112
|
-
});
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
### Parsing data
|
|
116
|
-
|
|
117
|
-
Given any Zod schema, use `.parse` to validate an input. If it's valid, Zod returns a strongly-typed _deep clone_ of the input.
|
|
118
|
-
|
|
119
|
-
```ts
|
|
120
|
-
Player.parse({ username: "billie", xp: 100 });
|
|
121
|
-
// => returns { username: "billie", xp: 100 }
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
**Note** — If your schema uses certain asynchronous APIs like `async` [refinements](#refine) or [transforms](#transform), you'll need to use the `.parseAsync()` method instead.
|
|
125
|
-
|
|
126
|
-
```ts
|
|
127
|
-
const schema = z.string().refine(async (val) => val.length <= 8);
|
|
128
|
-
|
|
129
|
-
await schema.parseAsync("hello");
|
|
130
|
-
// => "hello"
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
### Handling errors
|
|
134
|
-
|
|
135
|
-
When validation fails, the `.parse()` method will throw a `ZodError` instance with granular information about the validation issues.
|
|
136
|
-
|
|
137
|
-
```ts
|
|
138
|
-
try {
|
|
139
|
-
Player.parse({ username: 42, xp: "100" });
|
|
140
|
-
} catch (err) {
|
|
141
|
-
if (err instanceof z.ZodError) {
|
|
142
|
-
err.issues;
|
|
143
|
-
/* [
|
|
144
|
-
{
|
|
145
|
-
expected: 'string',
|
|
146
|
-
code: 'invalid_type',
|
|
147
|
-
path: [ 'username' ],
|
|
148
|
-
message: 'Invalid input: expected string'
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
expected: 'number',
|
|
152
|
-
code: 'invalid_type',
|
|
153
|
-
path: [ 'xp' ],
|
|
154
|
-
message: 'Invalid input: expected number'
|
|
155
|
-
}
|
|
156
|
-
] */
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
To avoid a `try/catch` block, you can use the `.safeParse()` method to get back a plain result object containing either the successfully parsed data or a `ZodError`. The result type is a [discriminated union](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#discriminated-unions), so you can handle both cases conveniently.
|
|
162
|
-
|
|
163
|
-
```ts
|
|
164
|
-
const result = Player.safeParse({ username: 42, xp: "100" });
|
|
165
|
-
if (!result.success) {
|
|
166
|
-
result.error; // ZodError instance
|
|
167
|
-
} else {
|
|
168
|
-
result.data; // { username: string; xp: number }
|
|
169
|
-
}
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
**Note** — If your schema uses certain asynchronous APIs like `async` [refinements](#refine) or [transforms](#transform), you'll need to use the `.safeParseAsync()` method instead.
|
|
173
|
-
|
|
174
|
-
```ts
|
|
175
|
-
const schema = z.string().refine(async (val) => val.length <= 8);
|
|
176
|
-
|
|
177
|
-
await schema.safeParseAsync("hello");
|
|
178
|
-
// => { success: true; data: "hello" }
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
### Inferring types
|
|
182
|
-
|
|
183
|
-
Zod infers a static type from your schema definitions. You can extract this type with the `z.infer<>` utility and use it however you like.
|
|
184
|
-
|
|
185
|
-
```ts
|
|
186
|
-
const Player = z.object({
|
|
187
|
-
username: z.string(),
|
|
188
|
-
xp: z.number(),
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
// extract the inferred type
|
|
192
|
-
type Player = z.infer<typeof Player>;
|
|
193
|
-
|
|
194
|
-
// use it in your code
|
|
195
|
-
const player: Player = { username: "billie", xp: 100 };
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
In some cases, the input & output types of a schema can diverge. For instance, the `.transform()` API can convert the input from one type to another. In these cases, you can extract the input and output types independently:
|
|
199
|
-
|
|
200
|
-
```ts
|
|
201
|
-
const mySchema = z.string().transform((val) => val.length);
|
|
202
|
-
|
|
203
|
-
type MySchemaIn = z.input<typeof mySchema>;
|
|
204
|
-
// => string
|
|
205
|
-
|
|
206
|
-
type MySchemaOut = z.output<typeof mySchema>; // equivalent to z.infer<typeof mySchema>
|
|
207
|
-
// number
|
|
208
|
-
```
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
export { default as ar } from "./ar.cjs";
|
|
2
|
-
export { default as az } from "./az.cjs";
|
|
3
|
-
export { default as be } from "./be.cjs";
|
|
4
|
-
export { default as ca } from "./ca.cjs";
|
|
5
|
-
export { default as cs } from "./cs.cjs";
|
|
6
|
-
export { default as de } from "./de.cjs";
|
|
7
|
-
export { default as en } from "./en.cjs";
|
|
8
|
-
export { default as eo } from "./eo.cjs";
|
|
9
|
-
export { default as es } from "./es.cjs";
|
|
10
|
-
export { default as fa } from "./fa.cjs";
|
|
11
|
-
export { default as fi } from "./fi.cjs";
|
|
12
|
-
export { default as fr } from "./fr.cjs";
|
|
13
|
-
export { default as frCA } from "./fr-CA.cjs";
|
|
14
|
-
export { default as he } from "./he.cjs";
|
|
15
|
-
export { default as hu } from "./hu.cjs";
|
|
16
|
-
export { default as id } from "./id.cjs";
|
|
17
|
-
export { default as it } from "./it.cjs";
|
|
18
|
-
export { default as ja } from "./ja.cjs";
|
|
19
|
-
export { default as kh } from "./kh.cjs";
|
|
20
|
-
export { default as ko } from "./ko.cjs";
|
|
21
|
-
export { default as mk } from "./mk.cjs";
|
|
22
|
-
export { default as ms } from "./ms.cjs";
|
|
23
|
-
export { default as nl } from "./nl.cjs";
|
|
24
|
-
export { default as no } from "./no.cjs";
|
|
25
|
-
export { default as ota } from "./ota.cjs";
|
|
26
|
-
export { default as ps } from "./ps.cjs";
|
|
27
|
-
export { default as pl } from "./pl.cjs";
|
|
28
|
-
export { default as pt } from "./pt.cjs";
|
|
29
|
-
export { default as ru } from "./ru.cjs";
|
|
30
|
-
export { default as sl } from "./sl.cjs";
|
|
31
|
-
export { default as sv } from "./sv.cjs";
|
|
32
|
-
export { default as ta } from "./ta.cjs";
|
|
33
|
-
export { default as th } from "./th.cjs";
|
|
34
|
-
export { default as tr } from "./tr.cjs";
|
|
35
|
-
export { default as ua } from "./ua.cjs";
|
|
36
|
-
export { default as ur } from "./ur.cjs";
|
|
37
|
-
export { default as vi } from "./vi.cjs";
|
|
38
|
-
export { default as zhCN } from "./zh-CN.cjs";
|
|
39
|
-
export { default as zhTW } from "./zh-TW.cjs";
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
export { default as ar } from "./ar.js";
|
|
2
|
-
export { default as az } from "./az.js";
|
|
3
|
-
export { default as be } from "./be.js";
|
|
4
|
-
export { default as ca } from "./ca.js";
|
|
5
|
-
export { default as cs } from "./cs.js";
|
|
6
|
-
export { default as de } from "./de.js";
|
|
7
|
-
export { default as en } from "./en.js";
|
|
8
|
-
export { default as eo } from "./eo.js";
|
|
9
|
-
export { default as es } from "./es.js";
|
|
10
|
-
export { default as fa } from "./fa.js";
|
|
11
|
-
export { default as fi } from "./fi.js";
|
|
12
|
-
export { default as fr } from "./fr.js";
|
|
13
|
-
export { default as frCA } from "./fr-CA.js";
|
|
14
|
-
export { default as he } from "./he.js";
|
|
15
|
-
export { default as hu } from "./hu.js";
|
|
16
|
-
export { default as id } from "./id.js";
|
|
17
|
-
export { default as it } from "./it.js";
|
|
18
|
-
export { default as ja } from "./ja.js";
|
|
19
|
-
export { default as kh } from "./kh.js";
|
|
20
|
-
export { default as ko } from "./ko.js";
|
|
21
|
-
export { default as mk } from "./mk.js";
|
|
22
|
-
export { default as ms } from "./ms.js";
|
|
23
|
-
export { default as nl } from "./nl.js";
|
|
24
|
-
export { default as no } from "./no.js";
|
|
25
|
-
export { default as ota } from "./ota.js";
|
|
26
|
-
export { default as ps } from "./ps.js";
|
|
27
|
-
export { default as pl } from "./pl.js";
|
|
28
|
-
export { default as pt } from "./pt.js";
|
|
29
|
-
export { default as ru } from "./ru.js";
|
|
30
|
-
export { default as sl } from "./sl.js";
|
|
31
|
-
export { default as sv } from "./sv.js";
|
|
32
|
-
export { default as ta } from "./ta.js";
|
|
33
|
-
export { default as th } from "./th.js";
|
|
34
|
-
export { default as tr } from "./tr.js";
|
|
35
|
-
export { default as ua } from "./ua.js";
|
|
36
|
-
export { default as ur } from "./ur.js";
|
|
37
|
-
export { default as vi } from "./vi.js";
|
|
38
|
-
export { default as zhCN } from "./zh-CN.js";
|
|
39
|
-
export { default as zhTW } from "./zh-TW.js";
|