{"id":19644292,"url":"https://github.com/jettcalleja/csv-validator","last_synced_at":"2025-06-25T19:02:42.979Z","repository":{"id":71391078,"uuid":"109089417","full_name":"jettcalleja/csv-validator","owner":"jettcalleja","description":"nodejs validator for csv file","archived":false,"fork":false,"pushed_at":"2023-04-19T09:37:36.000Z","size":59,"stargazers_count":3,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-25T19:02:28.883Z","etag":null,"topics":["csv","csv-validator","nodejs","validator"],"latest_commit_sha":null,"homepage":"","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/jettcalleja.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":"2017-11-01T05:08:39.000Z","updated_at":"2023-04-19T09:37:57.000Z","dependencies_parsed_at":"2024-06-18T22:58:52.031Z","dependency_job_id":null,"html_url":"https://github.com/jettcalleja/csv-validator","commit_stats":{"total_commits":12,"total_committers":1,"mean_commits":12.0,"dds":0.0,"last_synced_commit":"f9b3cfb649a9460cbc8603266cacf7c5c2e1d216"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jettcalleja/csv-validator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jettcalleja%2Fcsv-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jettcalleja%2Fcsv-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jettcalleja%2Fcsv-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jettcalleja%2Fcsv-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jettcalleja","download_url":"https://codeload.github.com/jettcalleja/csv-validator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jettcalleja%2Fcsv-validator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261937022,"owners_count":23232843,"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-validator","nodejs","validator"],"created_at":"2024-11-11T14:26:33.160Z","updated_at":"2025-06-25T19:02:42.952Z","avatar_url":"https://github.com/jettcalleja.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `csv-validator`\n\nnodejs validator for csv file\n\n# Features\n\n* Parse csv (supports only file as of now) and convert to json array\n* Validate each line with type or RegExp\n* Return each line's error with error message\n* Support callback and promise\n* Non-blocking parsing\n\n# Install\n\n```sh\nnpm install csv-validator --save\n```\n\n# Example\n\nWithout errors:\n\n```javascript\n/** csv file\nname,phone,email,country\njohn,123,john@ph.com,PH\ndoe,456,doe@us.com,US\n*/\n\nconst csv = require('csv-validator');\nconst csvFilePath = '\u003cpath to csv file\u003e';\nconst headers = {\n    name: '', // any string\n    phone: 1, // any number\n    email: /^(([^\u003c\u003e()[\\]\\\\.,;:\\s@\\\"]+(\\.[^\u003c\u003e()[\\]\\\\.,;:\\s@\\\"]+)*)|(\\\".+\\\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/, // RegExp\n    _country: '' // add '_' as first character of the key to indicate as optional\n};\n\ncsv(csvFilePath, headers)\n    .then(console.log) // [ { name: 'john', phone: '123', email: 'john@ph.com', country: 'PH' }, { name: 'doe', phone: '456', email: 'doe@us.com', country: 'US' } ]\n```\n\nWith error:\n\n```javascript\n/** csv file\nname,phone,email,country\njohn,123a,john@ph.com,PH\ndoe,456,doe@us.com\n*/\n\nconst csv = require('csv-validator');\nconst csvFilePath = '\u003cpath to csv file\u003e';\nconst headers = {\n    name: '', // any string\n    phone: 1, // any number\n    email: /^(([^\u003c\u003e()[\\]\\\\.,;:\\s@\\\"]+(\\.[^\u003c\u003e()[\\]\\\\.,;:\\s@\\\"]+)*)|(\\\".+\\\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/, // RegExp\n    country: '' // add '_' as first character of the key to indicate as optional\n};\n\ncsv(csvFilePath, headers)\n    .then(console.log)\n    .catch(console.error) // [ 'Row 1: phone must be a type number', 'Row 2: country is required' ]\n```\n\nError messages:\n\n* **... must be a type number**: the column should be a number\n* **... is required**: the column should be filled\n* **... must be in /^[0-9]?.*/**: the column should be in RegExp (in this example: /^[0-9]?$/)\n\n# Contribution \n\n* Any pull request for new features and bug fixes is appreciated.\n* Just make sure to add test.\n\n# LICENSE\n\nMIT","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjettcalleja%2Fcsv-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjettcalleja%2Fcsv-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjettcalleja%2Fcsv-validator/lists"}