{"id":21541766,"url":"https://github.com/stefandanaita/csvvalidator","last_synced_at":"2025-08-24T17:38:51.551Z","repository":{"id":52452963,"uuid":"68756866","full_name":"stefandanaita/CsvValidator","owner":"stefandanaita","description":"A CSV Validator based on Laravel's built-in Validator","archived":false,"fork":false,"pushed_at":"2021-04-28T21:42:42.000Z","size":18,"stargazers_count":0,"open_issues_count":2,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-17T22:59:32.533Z","etag":null,"topics":["csv","csv-validator","encoding","laravel-csv","validator"],"latest_commit_sha":null,"homepage":null,"language":"PHP","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/stefandanaita.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}},"created_at":"2016-09-20T21:59:24.000Z","updated_at":"2017-05-15T14:07:52.000Z","dependencies_parsed_at":"2022-08-30T02:10:53.795Z","dependency_job_id":null,"html_url":"https://github.com/stefandanaita/CsvValidator","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefandanaita%2FCsvValidator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefandanaita%2FCsvValidator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefandanaita%2FCsvValidator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefandanaita%2FCsvValidator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stefandanaita","download_url":"https://codeload.github.com/stefandanaita/CsvValidator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244124179,"owners_count":20401683,"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","encoding","laravel-csv","validator"],"created_at":"2024-11-24T05:07:32.643Z","updated_at":"2025-03-17T22:59:36.822Z","avatar_url":"https://github.com/stefandanaita.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Installation\n\nExecute composer command.\n\n    composer require dsa-io/csv-validator:1.*\n\nRegister the service provider in app.php\n\n    'providers' =\u003e [\n        ...Others...,\n        Dsaio\\CsvValidator\\CsvValidatorServiceProvider::class,\n    ]\n\nAlso alias\n\n    'aliases' =\u003e [\n        ...Others...,  \n        'CsvValidator' =\u003e Dsaio\\CsvValidator\\Facades\\CsvValidator::class,\n    ]\n    \n# Basic usage\n\n    $csv_path = 'test.csv';\n    $rules = [\n        0 =\u003e 'required',\n        1 =\u003e 'required|integer',\n        2 =\u003e 'required|min:4'\n    ];\n    $csv_validator = CsvValidator::make($csv_path, $rules);\n    \n    if($csv_validator-\u003efails()) {\n        $errors = $csv_validator-\u003egetErrors();\n    }    \n\n# Rules\n\nYou can set keys instead of indexes like so.\n\n    $rules = [\n        'First Name' =\u003e 'required',\n        'Last Name' =\u003e 'required',\n        'Email' =\u003e 'required|email'\n    ];\n\nIn this case, the heading row of the CSV need to have `First Name`, `Last Name` and `Email`.  \nAnd This keys will be used as attribute names for error message.\n\n* [See](https://laravel.com/docs/5.2/validation#available-validation-rules) the details of the rules. \n\n# Trimming\n\nYou can set the 3rd argument a boolean value. If it is set to true, it will trim the cells of the csv. (Default: true)\n\n    CsvValidator::make($csv_path, $rules, true, 'SJIS-win');\n\n# Encoding\n\nYou can set a specific encoding as the 4th argument. (Default: UTF-8)\n\n    CsvValidator::make($csv_path, $rules, 'SJIS-win');\n\n# Error messages\n\nYou can get error messages after calling fails().\n\n    $errors = $csv_validator-\u003egetErrors();\n    \n    foreach ($errors as $row_index =\u003e $error) {\n    \n        foreach ($error as $col_index =\u003e $messages) {\n    \n            echo 'Row '. $row_index .', Col '.$col_index .': '. implode(',', $messages) .'\u003cbr\u003e';\n    \n        }\n    \n    }\n\n# Exception\n\nIf the validator is expecting a heading row (i.e it receives an associative rules array) and the CSV is empty, an exception will be thrown.\n\n# License\n\nThis package is licensed under the MIT License.\n\nCopyright 2017 DSA\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefandanaita%2Fcsvvalidator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstefandanaita%2Fcsvvalidator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefandanaita%2Fcsvvalidator/lists"}