PHPackages                             dsa-io/csv-validator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PDF &amp; Document Generation](/categories/documents)
4. /
5. dsa-io/csv-validator

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

dsa-io/csv-validator
====================

A CSV Validator based on Laravel's built-in Validator

1.1.3(9y ago)01541[2 PRs](https://github.com/stefandanaita/CsvValidator/pulls)MITPHP

Since Jan 25Pushed 5y agoCompare

[ Source](https://github.com/stefandanaita/CsvValidator)[ Packagist](https://packagist.org/packages/dsa-io/csv-validator)[ RSS](/packages/dsa-io-csv-validator/feed)WikiDiscussions master Synced yesterday

READMEChangelog (4)Dependencies (1)Versions (9)Used By (0)

Installation
============

[](#installation)

Execute composer command.

```
composer require dsa-io/csv-validator:1.*

```

Register the service provider in app.php

```
'providers' => [
    ...Others...,
    Dsaio\CsvValidator\CsvValidatorServiceProvider::class,
]

```

Also alias

```
'aliases' => [
    ...Others...,
    'CsvValidator' => Dsaio\CsvValidator\Facades\CsvValidator::class,
]

```

Basic usage
===========

[](#basic-usage)

```
$csv_path = 'test.csv';
$rules = [
    0 => 'required',
    1 => 'required|integer',
    2 => 'required|min:4'
];
$csv_validator = CsvValidator::make($csv_path, $rules);

if($csv_validator->fails()) {
    $errors = $csv_validator->getErrors();
}

```

Rules
=====

[](#rules)

You can set keys instead of indexes like so.

```
$rules = [
    'First Name' => 'required',
    'Last Name' => 'required',
    'Email' => 'required|email'
];

```

In this case, the heading row of the CSV need to have `First Name`, `Last Name` and `Email`.
And This keys will be used as attribute names for error message.

- [See](https://laravel.com/docs/5.2/validation#available-validation-rules) the details of the rules.

Trimming
========

[](#trimming)

You can set the 3rd argument a boolean value. If it is set to true, it will trim the cells of the csv. (Default: true)

```
CsvValidator::make($csv_path, $rules, true, 'SJIS-win');

```

Encoding
========

[](#encoding)

You can set a specific encoding as the 4th argument. (Default: UTF-8)

```
CsvValidator::make($csv_path, $rules, 'SJIS-win');

```

Error messages
==============

[](#error-messages)

You can get error messages after calling fails().

```
$errors = $csv_validator->getErrors();

foreach ($errors as $row_index => $error) {

    foreach ($error as $col_index => $messages) {

        echo 'Row '. $row_index .', Col '.$col_index .': '. implode(',', $messages) .'';

    }

}

```

Exception
=========

[](#exception)

If 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.

License
=======

[](#license)

This package is licensed under the MIT License.

Copyright 2017 DSA

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~25 days

Recently: every ~31 days

Total

6

Last Release

3316d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/9030768?v=4)[Stefan Danaita](/maintainers/stefandanaita)[@stefandanaita](https://github.com/stefandanaita)

---

Top Contributors

[![stefandanaita](https://avatars.githubusercontent.com/u/9030768?v=4)](https://github.com/stefandanaita "stefandanaita (28 commits)")

---

Tags

csvcsv-validatorencodinglaravel-csvvalidatorlaravelvalidatorcsv

### Embed Badge

![Health badge](/badges/dsa-io-csv-validator/health.svg)

```
[![Health](https://phpackages.com/badges/dsa-io-csv-validator/health.svg)](https://phpackages.com/packages/dsa-io-csv-validator)
```

###  Alternatives

[bfinlay/laravel-excel-seeder

Seed the database with Laravel using Excel, XLSX, XLS, CSV, ODS, Gnumeric, XML, HTML, SLK files

3946.9k](/packages/bfinlay-laravel-excel-seeder)[ecotone/laravel

Ecotone for Laravel — CQRS, Event Sourcing, Sagas, Durable Workflows, and Outbox on top of Laravel Queue, via PHP attributes.

21318.6k3](/packages/ecotone-laravel)[crockett/csv-seeder

Database seeding using CSV files

23176.7k](/packages/crockett-csv-seeder)[initred/laravel-tabula

laravel-tabula is a tool for liberating data tables trapped inside PDF files for the Laravel framework.

1418.6k](/packages/initred-laravel-tabula)[nilgems/laravel-textract

A Laravel package to extract text from files like DOC, XL, Image, Pdf and more. I've developed this package by inspiring "npm textract".

195.7k](/packages/nilgems-laravel-textract)[rgilyov/laravel-csv-importer

Easy and reliable way to import, parse, validate and transform your csv files with laravel

166.1k](/packages/rgilyov-laravel-csv-importer)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
