{"id":31796409,"url":"https://github.com/sidwebworks/zod-xlsx","last_synced_at":"2025-10-10T20:48:30.702Z","repository":{"id":46886655,"uuid":"502866890","full_name":"sidwebworks/zod-xlsx","owner":"sidwebworks","description":"A xlsx based resource validator using Zod schemas for data imports and more","archived":false,"fork":false,"pushed_at":"2025-06-15T13:16:37.000Z","size":153,"stargazers_count":46,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-29T12:40:25.270Z","etag":null,"topics":["async-validation","node","validation","xlsx","zod"],"latest_commit_sha":null,"homepage":"","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/sidwebworks.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2022-06-13T08:17:49.000Z","updated_at":"2025-09-27T15:52:07.000Z","dependencies_parsed_at":"2024-06-21T12:14:15.518Z","dependency_job_id":"f0fefe4d-f9d6-43a4-a756-7845f9d4c846","html_url":"https://github.com/sidwebworks/zod-xlsx","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/sidwebworks/zod-xlsx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sidwebworks%2Fzod-xlsx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sidwebworks%2Fzod-xlsx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sidwebworks%2Fzod-xlsx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sidwebworks%2Fzod-xlsx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sidwebworks","download_url":"https://codeload.github.com/sidwebworks/zod-xlsx/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sidwebworks%2Fzod-xlsx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279005268,"owners_count":26083864,"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","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["async-validation","node","validation","xlsx","zod"],"created_at":"2025-10-10T20:48:16.376Z","updated_at":"2025-10-10T20:48:30.696Z","avatar_url":"https://github.com/sidwebworks.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ZOD-XLSX\n\n[![npm version](https://badgen.net/npm/v/zod-xlsx)](https://www.npmjs.com/package/zod-xlsx)\n![npm downloads](https://badgen.net/npm/dt/zod-xlsx)\n[![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)\n\n\u003e A xlsx based resource validator using Zod schemas\n\n**Supports both ESM and CJS**\n\n## Installation\n\n\u003e Note:\n\u003e This package requires [Zod](https://www.npmjs.com/package/zod) and [xlsx](https://www.npmjs.com/package/xlsx) as peer dependencies\n\n```bash\n# With npm\nnpm install zod-xlsx xlsx zod\n\n# With yarn\nyarn add zod-xlsx xlsx zod\n\n# With pnpm\npnpm add zod-xlsx xlsx zod\n```\n\n## Usage\n\nThe library exports a single function called `createValidator` which takes in a xlsx workbook and creates a validator object.\n\nPlease make sure your top row of the sheet (xlsx or xls) file contains only header content for the columns as it's required for the library to function properly.\n\n```ts\nimport { createValidator } from \"zod-xlsx\"\nimport xlsx from \"xlsx\"\n\nconst workbook = xlsx.readFile(/*path to your file*/)\n\nconst validator = createValidator(workbook)\n\nconst schema = z.object({\n  \"First Name\": z.string(),\n  \"Last Name\": z.string(),\n  Gender: z.enum([\"Male\", \"Female\"]),\n  Country: z.string(),\n  Age: z.number(),\n  Date: z.string(),\n  Id: z.number(),\n})\n\nconst result = validator.validate(schema)\n```\n\n**OUTPUT**\n\n```js\n{\n  valid: [\n    { issues: [], isValid: true, data: [Object] },\n    { issues: [], isValid: true, data: [Object] },\n    { issues: [], isValid: true, data: [Object] },\n    { issues: [], isValid: true, data: [Object] },\n  ]\n  invalid: [\n    { issues: [Object], isValid: false, data: [Object] },\n    { issues: [Object], isValid: false, data: [Object] },\n    { issues: [Object], isValid: false, data: [Object] },\n  ]\n}\n```\n\n## API Reference\n\n### **createValidator**\n\nFunction to create a new validator object with the given workbook.\nIt takes an options object as the second arguement.\n\n```ts\nexport interface ValidatorOptions {\n  // Comes from xlsx\n  header?: Sheet2JSONOpts[\"header\"]\n  blankrows?: Sheet2JSONOpts[\"blankrows\"]\n  skipHidden?: Sheet2JSONOpts[\"skipHidden\"]\n\n  // Zod-xlsx options\n  sheetName?: string\n  onValid?: (data: any) =\u003e void\n  onInvalid?: (data: any) =\u003e void\n}\n```\n\n- **sheetName**: name of the sheet to use, defaults to the first sheet in the document.\n\n- **onValid**: hook which gets called after every valid item is processed.\n\n- **onValid**: hook which gets called after every invalid item is processed.\n\n\u003e For details on what each of the xlsx option does can be found: [Here](https://docs.sheetjs.com/docs/api/utilities#json)\n\n### **validator.validate()**\n\nSynchronously parses all the rows against the given schema and returns the result.\n\n### **validator.validateAsync()**\n\nAsynchronously parses all the rows against the given schema _without blocking the event loop_, it does this using batch processing.\n(500 is the default batch size)\n\nDepending on your usecase, its possible to configure the `batchSize` like so: `validateAsync(schema, { batchSize: 500 })`.\n\n## License\n\nMIT \u0026copy; [sidwebworks](https://github.com/sidwebworks)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsidwebworks%2Fzod-xlsx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsidwebworks%2Fzod-xlsx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsidwebworks%2Fzod-xlsx/lists"}