{"id":29143416,"url":"https://github.com/yuzheng14/valype","last_synced_at":"2025-06-30T20:07:20.760Z","repository":{"id":219140834,"uuid":"748279280","full_name":"yuzheng14/valype","owner":"yuzheng14","description":"Valype = Validate + Type. Automatically generates runtime validators from TypeScript type definitions.","archived":false,"fork":false,"pushed_at":"2025-06-25T05:10:55.000Z","size":310,"stargazers_count":22,"open_issues_count":11,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-25T06:24:39.728Z","etag":null,"topics":["farm","rollup","runtime-validation","schema-validation","static-types","tsdown","type-inference","typecheck","typechecker","typescript","unplugin","validate","validation","validator","vite","webpack","zod"],"latest_commit_sha":null,"homepage":"https://valype.dev","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yuzheng14.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-01-25T16:42:15.000Z","updated_at":"2025-06-24T17:18:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"ce2678b5-f75e-4f26-89dc-806ac1fe6030","html_url":"https://github.com/yuzheng14/valype","commit_stats":null,"previous_names":["yuzheng14/valype"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/yuzheng14/valype","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuzheng14%2Fvalype","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuzheng14%2Fvalype/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuzheng14%2Fvalype/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuzheng14%2Fvalype/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yuzheng14","download_url":"https://codeload.github.com/yuzheng14/valype/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuzheng14%2Fvalype/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262784568,"owners_count":23363738,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["farm","rollup","runtime-validation","schema-validation","static-types","tsdown","type-inference","typecheck","typechecker","typescript","unplugin","validate","validation","validator","vite","webpack","zod"],"created_at":"2025-06-30T20:07:18.440Z","updated_at":"2025-06-30T20:07:20.704Z","avatar_url":"https://github.com/yuzheng14.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg width=\"180\" src=\"./assets/logo.svg\" alt=\"Valype log\"\u003e\n\u003c/p\u003e\n\u003cbr /\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.npmjs.com/package/valype\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/valype?color=a1b858\u0026label=\" alt=\"valype version\"\u003e\u003c/a\u003e\n  \u003ca href=\"./LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/npm/l/valype\" alt=\"valype license\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003cbr/\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"./README.zh-CN.md\"\u003e[中文]\u003c/a\u003e | \u003ca href=\"./README.md\"\u003e[English]\u003c/a\u003e\n\u003c/p\u003e\n\u003cbr /\u003e\n\n# Valype 🐉\n\n![Alt](https://repobeats.axiom.co/api/embed/21d8a2a1bd32ca3de06711098fe077905c5e8adf.svg 'Repobeats analytics image')\n\n**TypeScript Runtime Validator** - Generate validation from type definitions\n\n\u003e [!WARNING]\n\u003e\n\u003e Valype is currently under active development. APIs may change in future releases. Please follow [Semver](https://semver.org/) to avoid **breaking changes**.\n\n- 🎯 Type-safe validation with TypeScript type inference\n- 🔌 Seamless unplugin integration (Vite/Rollup/esbuild/Astro/Farm/Nuxt/Rspack/Webpack)\n- 🛡️ Unified type validation\n- 💻 TypeScript plugin for IDE support\n- 🚧 IDE/editor extension support (WIP)\n\nValype = Validate + Type. Automatically generates runtime validators from TypeScript type definitions.\n\n## 🚀 Getting Started\n\n1. Install plugin:\n\n```bash\n# for npm users\nnpm add zod@latest\nnpm add -D unplugin-valype\n\n# for yarn users\nyarn add zod@latest\nyarn add -D unplugin-valype\n\n# for pnp users\npnpm add zod@latest\npnpm add -D unplugin-valype\n\n# for bun users\nbun add zod@latest\nbun add -D unplugin-valype\n```\n\n\u003e zod's version should be `3.25.0` at least, because valype generates zod v4 schema\n\n2. Configure plugin for your build tool following [unplugin-valype docs](./packages/plugin/README.md)\n\n3. For TypeScript language support, install the plugin:\n\n```bash\nnpm install -D @valype/typescript-plugin\n```\n\nThen add to your tsconfig.json:\n\n```json\n{\n  \"compilerOptions\": {\n    \"plugins\": [\n      {\n        \"name\": \"@valype/typescript-plugin\"\n      }\n    ]\n  }\n}\n```\n\n\u003e For VSCode users, ensure you're using the workspace version of TypeScript\n\n4. Define your types (use `.valype.ts` extension):\n\n```typescript\n// user.valype.ts\nexport interface User {\n  name: string\n  age: number\n}\n```\n\n4. Use the generated validator:\n\n```typescript\nimport { validateUser } from './user.valype'\n\nconst issues = validateUser(data) // Returns ZodIssue[] or undefined\nif (issues) {\n  // Handle validation errors\n}\n```\n\n## 📖 Usage\n\n`unplugin-valype` generates validators for types exported from `*.valype.ts` files. The validator type signature is:\n\n```typescript\nexport declare function validateSome(data: unknown): ZodIssue[] | undefined\n```\n\n- Returns `undefined` when validation passes\n- Returns `ZodIssue[]` with error details when validation fails\n\n\u003e [!NOTE]\n\u003e\n\u003e You typically don't need to use `valype` package directly, just use the generated validators.\n\n## 📦 Packages\n\n| Package                                                          | Version                                                                                                                                       | Description                  |\n| ---------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- |\n| [valype](https://www.npmjs.com/package/valype)                   | [![valype version](https://img.shields.io/npm/v/valype?color=a1b858\u0026label=)](https://www.npmjs.com/package/valype)                            | Core schema generation logic |\n| [unplugin-valype](https://www.npmjs.com/package/unplugin-valype) | [![unplugin-valype version](https://img.shields.io/npm/v/unplugin-valype?color=a1b858\u0026label=)](https://www.npmjs.com/package/unplugin-valype) | Build tool plugin            |\n\n## 💡 Motivation\n\nWhile TypeScript ensures compile-time type safety, runtime data validation remains essential. Traditional solutions like Zod require duplicate type definitions and lose valuable tsdoc information. Valype solves this by:\n\n- **Single Source of Truth** - Define types once, get both static and runtime validation\n- **Full Type Information** - Preserves all tsdoc documentation and editor hints\n- **Seamless Integration** - Works natively with TypeScript tooling\n\n```typescript\nconst userSchema = z.object({\n  name: z.string(),\n  age: z.number(),\n})\n\ntype User = z.infer\u003ctypeof userSchema\u003e\n// And `User['name'] does not have tsdoc info\n```\n\nUsing valype:\n\n```typescript\nexport interface User {\n  /**\n   * name of user\n   */\n  name: string\n  age: number\n}\n\n// Validator is generated automatically!\nconst result = validateUser(data)\n\n// Also `User['name'] has tsdoc info\n```\n\nValype lets you **define types once** and get runtime validation automatically!\n\n## 🥰 Contributing\n\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\n## 🪪 License\n\n[MIT](./LICENSE)\n\n## 🙏 Inspired By\n\nValype draws inspiration from these excellent projects:\n\n- [ts-to-zod](https://github.com/fabien0102/ts-to-zod)\n- [Zod](https://github.com/colinhacks/zod)\n- [@sinclair/typebox](https://github.com/sinclairzx81/typebox)\n\n## 🌟 Star History\n\n[![Star History Chart](https://api.star-history.com/svg?repos=yuzheng14/valype\u0026type=Date)](https://www.star-history.com/#yuzheng14/valype\u0026Date)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuzheng14%2Fvalype","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyuzheng14%2Fvalype","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuzheng14%2Fvalype/lists"}