{"id":19399004,"url":"https://github.com/daviaquino87/validator-csv","last_synced_at":"2025-04-24T06:31:38.338Z","repository":{"id":197862889,"uuid":"699527262","full_name":"daviaquino87/validator-csv","owner":"daviaquino87","description":"The \"Validator CSV\" package is a powerful and easy-to-use tool for checking the integrity and quality of CSV files. With it, you can ensure that your CSV files are well formatted, meet header specifications, and meet your application's specific requirements.","archived":false,"fork":false,"pushed_at":"2023-10-24T13:32:35.000Z","size":47,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-16T16:14:54.084Z","etag":null,"topics":["csv","csv-files","javascript","js","nodejs","npm-package"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/validator-csv","language":"JavaScript","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/daviaquino87.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-10-02T20:08:26.000Z","updated_at":"2023-10-24T14:38:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"3ec1b16b-bb12-4652-b6ff-2bac40efc30b","html_url":"https://github.com/daviaquino87/validator-csv","commit_stats":null,"previous_names":["daviaquino87/validator-csv"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daviaquino87%2Fvalidator-csv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daviaquino87%2Fvalidator-csv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daviaquino87%2Fvalidator-csv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daviaquino87%2Fvalidator-csv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daviaquino87","download_url":"https://codeload.github.com/daviaquino87/validator-csv/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250578137,"owners_count":21453250,"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":["csv","csv-files","javascript","js","nodejs","npm-package"],"created_at":"2024-11-10T11:07:54.484Z","updated_at":"2025-04-24T06:31:38.091Z","avatar_url":"https://github.com/daviaquino87.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# validator-csv\n\n[![npm version][npm-version-image]][npm-package-uri]\n[![License][license-image]][license-uri]\n[![NPM Downloads][npm-downloads-image]][npm-downloads-url]\n[![GitHub Issues][github-issues-image]][github-issues-uri]\n\nThe \"Validator CSV\" package is a powerful and easy-to-use tool for checking the integrity and quality of CSV files. With it, you can ensure that your CSV files are well formatted, meet header specifications, and meet your application's specific requirements.\n\n## Installation\n\nYou can install this package via npm. Make sure you have Node.js installed.\n\n```bash\nnpm i validator-csv\n```\n\n## Usage\nTo use validator-csv follow the examples:\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\nValidating CSV through file path\n```js\nconst path = require(\"node:path\");\n\nconst validator = require('validator-csv');\nconst Yup = require(\"yup\");\n\nconst filePath = path.resolve(__dirname, \"uploads\", \"clientes.csv\");\n\nconst validationSchema = Yup.object().shape({\n  age: Yup.number().min(18, \"Invalid age, the customer must be over 18 years old.\").required(\"The field age is required.\"),\n});\n\nvalidator.validateCSV({\n  filePath,\n  headers: [\"name\", \"age\", \"gender\"],\n  schema: validationSchema,\n}).then((data) =\u003e {\n  console.log(data);\n}).catch((error) =\u003e {\n  console.error(\"Error:\", error);\n});\n\n\n/*\ndata:{\n  headers: [\"name\",\"age\",\"gender\",\"erros\"],\n  rows: [\n    [\"John Smith\",18,\"male\",[]],\n  ]\n}\n*/\n```\n\u003cbr\u003e\n\u003cbr\u003e\n\nValidating CSV through buffer\n```js\nconst fs = require(\"node:fs\");\nconst path = require(\"node:path\");\n\nconst validator = require('validator-csv');\nconst Yup = require(\"yup\");\n\nconst filePath = path.join(__dirname, \"uploads\", \"clientes.csv\");\nconst csvBuffer = fs.readFileSync(filePath);\n\nconst validationSchema = Yup.object().shape({\n  age: Yup.number().min(18, \"Invalid age, the customer must be over 18 years old.\").required(\"The field age is required.\"),\n});\n\nvalidator\n  .validateCSVFromBuffer({\n    buffer: csvBuffer,\n    headers: [\"name\", \"age\", \"gender\"],\n    schema: validationSchema,\n  })\n  .then((data) =\u003e {\n    console.log(data);\n  })\n  .catch((error) =\u003e {\n    console.error(\"Error:\", error);\n  });\n\n\n/*\ndata:{\n  headers: [\"name\",\"age\",\"gender\",\"erros\"],\n  rows: [\n    [\"John Smith\",18,\"male\",[]],\n  ]\n}\n*/\n```\n\n### info:\n\nBy default, the separator parameter is set to a comma (\",\"), but this setting can be modified by the user as needed.\n\nImportant Note About the Escape Character\n\nWhen the text is encapsulated in double quotes (\"), the separator will not impact the lines, thus ensuring the integrity of the data contained in the quotes.\n\nex: \n```js\nvalidator.validateCSV({\n  filePath: filePath,\n  headers: [\"name\", \"age\", \"gender\"],\n  separator: \";\",\n  schema: validationSchema,\n}).then((data) =\u003e {\n  console.log(data);\n});\n```\n\n\n## Validation functions\n\nExample of custom function with yup\n\n```js\nconst validationSchema = Yup.object().shape({\n  age: Yup.number().test(\"validate-age\",\"Invalid age, the customer must be over 18 years old.\",(element) =\u003e {\n    element \u003e= 18\n  })\n});\n```\n\n## Examples\n\nTo view the examples, clone the Express repo and install the dependencies:\n\n```sh\n$ git clone --branch examples https://github.com/daviaquino87/validator-csv \n\n$ cd validator-csv\n\n$ npm install\n\n$ npm run start\n```\n\n# People\n\nThe original author of validator-csv is [Davi Aquino](https://github.com/daviaquino87).\n\n## Licença\n\n[MIT](LICENSE.md).\n\n\n[npm-downloads-image]: https://badgen.net/npm/dm/express\n[npm-downloads-url]: https://npmcharts.com/compare/validator-csv?minimal=true\n[npm-version-image]: https://img.shields.io/npm/v/validator-csv\n[npm-package-uri]: https://www.npmjs.com/package/validator-csv\n[license-image]: https://img.shields.io/npm/l/validator-csv\n[license-uri]: https://github.com/daviaquino87/seu-pacote/blob/main/LICENSE\n[github-issues-image]: https://img.shields.io/github/issues/daviaquino87/validator-csv\n[github-issues-uri]: https://github.com/daviaquino87/validator-csv/issues","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaviaquino87%2Fvalidator-csv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaviaquino87%2Fvalidator-csv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaviaquino87%2Fvalidator-csv/lists"}