[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-1093":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":25,"hasPages":23,"topics":26,"createdAt":10,"pushedAt":10,"updatedAt":32,"readmeContent":33,"aiSummary":34,"trendingCount":16,"starSnapshotCount":16,"syncStatus":35,"lastSyncTime":36,"discoverSource":37},1093,"zod","colinhacks\u002Fzod","colinhacks","TypeScript-first schema validation with static type inference","https:\u002F\u002Fzod.dev",null,"TypeScript",42933,2014,80,93,0,12,70,293,59,119.91,"MIT License",false,"main",true,[27,28,29,30,31],"runtime-validation","schema-validation","static-types","type-inference","typescript","2026-06-12 04:00:07","\u003Cp align=\"center\">\n  \u003Cimg src=\"logo.svg\" width=\"200px\" align=\"center\" alt=\"Zod logo\" \u002F>\n  \u003Ch1 align=\"center\">Zod\u003C\u002Fh1>\n  \u003Cp align=\"center\">\n    TypeScript-first schema validation with static type inference\n    \u003Cbr\u002F>\n    by \u003Ca href=\"https:\u002F\u002Fx.com\u002Fcolinhacks\">@colinhacks\u003C\u002Fa>\n  \u003C\u002Fp>\n\u003C\u002Fp>\n\u003Cbr\u002F>\n\n\u003Cp align=\"center\">\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fcolinhacks\u002Fzod\u002Factions?query=branch%3Amain\">\u003Cimg src=\"https:\u002F\u002Fgithub.com\u002Fcolinhacks\u002Fzod\u002Factions\u002Fworkflows\u002Ftest.yml\u002Fbadge.svg?event=push&branch=main\" alt=\"Zod CI status\" \u002F>\u003C\u002Fa>\n\u003Ca href=\"https:\u002F\u002Fopensource.org\u002Flicenses\u002FMIT\" rel=\"nofollow\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Flicense\u002Fcolinhacks\u002Fzod\" alt=\"License\">\u003C\u002Fa>\n\u003Ca href=\"https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002Fzod\" rel=\"nofollow\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fnpm\u002Fdw\u002Fzod.svg\" alt=\"npm\">\u003C\u002Fa>\n\u003Ca href=\"https:\u002F\u002Fdiscord.gg\u002FKaSRdyX2vc\" rel=\"nofollow\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fdiscord\u002F893487829802418277?label=Discord&logo=discord&logoColor=white\" alt=\"discord server\">\u003C\u002Fa>\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fcolinhacks\u002Fzod\" rel=\"nofollow\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Fstars\u002Fcolinhacks\u002Fzod\" alt=\"stars\">\u003C\u002Fa>\n\u003C\u002Fp>\n\n\u003Cdiv align=\"center\">\n  \u003Ca href=\"https:\u002F\u002Fzod.dev\u002Fapi\">Docs\u003C\u002Fa>\n  \u003Cspan>&nbsp;&nbsp;•&nbsp;&nbsp;\u003C\u002Fspan>\n  \u003Ca href=\"https:\u002F\u002Fdiscord.gg\u002FRcG33DQJdf\">Discord\u003C\u002Fa>\n  \u003Cspan>&nbsp;&nbsp;•&nbsp;&nbsp;\u003C\u002Fspan>\n  \u003Ca href=\"https:\u002F\u002Ftwitter.com\u002Fcolinhacks\">𝕏\u003C\u002Fa>\n  \u003Cspan>&nbsp;&nbsp;•&nbsp;&nbsp;\u003C\u002Fspan>\n  \u003Ca href=\"https:\u002F\u002Fbsky.app\u002Fprofile\u002Fzod.dev\">Bluesky\u003C\u002Fa>\n  \u003Cbr \u002F>\n\u003C\u002Fdiv>\n\n\u003Cbr\u002F>\n\u003Cbr\u002F>\n\n### [Read the docs →](https:\u002F\u002Fzod.dev\u002Fapi)\n\n\u003Cbr\u002F>\n\u003Cbr\u002F>\n\n## What is Zod?\n\nZod is a TypeScript-first validation library. Define a schema and parse some data with it. You'll get back a strongly typed, validated result.\n\n```ts\nimport * as z from \"zod\";\n\nconst User = z.object({\n  name: z.string(),\n});\n\n\u002F\u002F some untrusted data...\nconst input = {\n  \u002F* stuff *\u002F\n};\n\n\u002F\u002F the parsed result is validated and type safe!\nconst data = User.parse(input);\n\n\u002F\u002F so you can use it with confidence :)\nconsole.log(data.name);\n```\n\n\u003Cbr\u002F>\n\n## Features\n\n- Zero external dependencies\n- Works in Node.js and all modern browsers\n- Tiny: `2kb` core bundle (gzipped)\n- Immutable API: methods return a new instance\n- Concise interface\n- Works with TypeScript and plain JS\n- Built-in JSON Schema conversion\n- Extensive ecosystem\n\n\u003Cbr\u002F>\n\n## Installation\n\n```sh\nnpm install zod\n```\n\n\u003Cbr\u002F>\n\n## Basic usage\n\nBefore you can do anything else, you need to define a schema. For the purposes of this guide, we'll use a simple object schema.\n\n```ts\nimport * as z from \"zod\";\n\nconst Player = z.object({\n  username: z.string(),\n  xp: z.number(),\n});\n```\n\n### Parsing data\n\nGiven any Zod schema, use `.parse` to validate an input. If it's valid, Zod returns a strongly-typed _deep clone_ of the input.\n\n```ts\nPlayer.parse({ username: \"billie\", xp: 100 });\n\u002F\u002F => returns { username: \"billie\", xp: 100 }\n```\n\n**Note** — If your schema uses certain asynchronous APIs like `async` [refinements](https:\u002F\u002Fzod.dev\u002Fapi#refinements) or [transforms](https:\u002F\u002Fzod.dev\u002Fapi#transforms), you'll need to use the `.parseAsync()` method instead.\n\n```ts\nconst schema = z.string().refine(async (val) => val.length \u003C= 8);\n\nawait schema.parseAsync(\"hello\");\n\u002F\u002F => \"hello\"\n```\n\n### Handling errors\n\nWhen validation fails, the `.parse()` method will throw a `ZodError` instance with granular information about the validation issues.\n\n```ts\ntry {\n  Player.parse({ username: 42, xp: \"100\" });\n} catch (err) {\n  if (err instanceof z.ZodError) {\n    err.issues;\n    \u002F* [\n      {\n        expected: 'string',\n        code: 'invalid_type',\n        path: [ 'username' ],\n        message: 'Invalid input: expected string'\n      },\n      {\n        expected: 'number',\n        code: 'invalid_type',\n        path: [ 'xp' ],\n        message: 'Invalid input: expected number'\n      }\n    ] *\u002F\n  }\n}\n```\n\nTo avoid a `try\u002Fcatch` 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:\u002F\u002Fwww.typescriptlang.org\u002Fdocs\u002Fhandbook\u002F2\u002Fnarrowing.html#discriminated-unions), so you can handle both cases conveniently.\n\n```ts\nconst result = Player.safeParse({ username: 42, xp: \"100\" });\nif (!result.success) {\n  result.error; \u002F\u002F ZodError instance\n} else {\n  result.data; \u002F\u002F { username: string; xp: number }\n}\n```\n\n**Note** — If your schema uses certain asynchronous APIs like `async` [refinements](https:\u002F\u002Fzod.dev\u002Fapi#refinements) or [transforms](https:\u002F\u002Fzod.dev\u002Fapi#transforms), you'll need to use the `.safeParseAsync()` method instead.\n\n```ts\nconst schema = z.string().refine(async (val) => val.length \u003C= 8);\n\nawait schema.safeParseAsync(\"hello\");\n\u002F\u002F => { success: true; data: \"hello\" }\n```\n\n### Inferring types\n\nZod infers a static type from your schema definitions. You can extract this type with the `z.infer\u003C>` utility and use it however you like.\n\n```ts\nconst Player = z.object({\n  username: z.string(),\n  xp: z.number(),\n});\n\n\u002F\u002F extract the inferred type\ntype Player = z.infer\u003Ctypeof Player>;\n\n\u002F\u002F use it in your code\nconst player: Player = { username: \"billie\", xp: 100 };\n```\n\nIn 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:\n\n```ts\nconst mySchema = z.string().transform((val) => val.length);\n\ntype MySchemaIn = z.input\u003Ctypeof mySchema>;\n\u002F\u002F => string\n\ntype MySchemaOut = z.output\u003Ctypeof mySchema>; \u002F\u002F equivalent to z.infer\u003Ctypeof mySchema>\n\u002F\u002F number\n```\n","Zod 是一个专注于 TypeScript 的模式验证库，支持静态类型推断。其核心功能包括定义模式并解析数据，确保返回的数据既经过验证又具有强类型安全。Zod 无外部依赖，适用于 Node.js 和现代浏览器环境，且核心包大小仅为 2KB（压缩后）。它提供了一套简洁且不可变的 API，并兼容纯 JavaScript 和 JSON Schema 转换。由于这些特性，Zod 非常适合需要在客户端或服务端进行严格数据校验和类型安全保证的应用场景中使用。",2,"2026-06-11 02:41:36","top_all"]