sukohi/csv-validator
Larablocks Analysis
sukohi/csv-validator works with Laravel 5 to 8 (latest release 3.0.4, Oct 2, 2020), all past end of life (the last on Jan 24, 2023): no more fixes, even for security.
Laravel 4 in earlier releases.
Recommendation checks
Not advisedNot advised: no release or commit in over 2 years.
- No release or commit in over 2 years
- Supports only Laravel 5 to 8, past end of life since Jan 24, 2023
- No release in the last 12 months (last: Oct 2, 2020)
- 1 downloads a month (needs 10,000)
- 8 GitHub stars (needs 100)
State
Likely abandoned- No release or commit in over 2 years.
- Last stable release: Oct 2, 2020.
- No releases in the last 12 months.
- First released: May 12, 2016.
- Monthly downloads: 1, down 97% from six months ago.
- 2 open issues on GitHub.
Data from Packagist and GitHub, checked by Larablocks on Dec 2, 2026.
| Install | |
|---|---|
composer require sukohi/csv-validator |
|
| Latest Version: | 3.0.4 |
| Laravel: | 5 – 8 |
| Older releases: | 4 |
| License: | MIT |
| Last Updated: | Oct 2, 2020 |
| Links: | GitHub · Packagist |
CsvValidator
A Laravel package that allows you to validate csv data.
This package is compatible with Laravel 5.7 -> 8.X
Installation
Run this command.
composer require sukohi/csv-validator:3.*
Basic usage
You can use a rule called Csv as usual validation.
And all the validation rules of Laravel is available for $csv_rules as follows.
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Sukohi\CsvValidator\Rules\Csv;
class CsvValidatorController extends Controller
{
public function store(Request $request) {
$csv_rules = [
0 => 'required',
1 => 'integer',
2 => 'required|min:10'
];
$request->validate([
'users_csv' => [
new Csv($csv_rules) // <- here
]
]);
// Do something..
}
}
with Options
$csv_rules = [
0 => 'required',
1 => 'integer',
2 => 'required|min:10'
];
$options = [
'encoding' => 'sjsin-win',
'start_row' => 1, // <- Starting validation from row one, not zero. (*1)
'end_row' => 4, // <- Ending validation
'row_callback' => function($row_number, $row_data) {
return true; // `false` means skipping validation
}
];
$request->validate([
'csv_file' => [
new Csv($csv_rules, $options)
]
]);
(*1) For example, if you don't want to validate the header row, it means the first row, set 2 here.
Note: The former coding is also available.
new Csv($csv_rules, 'sjis-win')
Csv rules
You can skip column like this.
$csv_rules = [
0 => 'required',
3 => 'required|min:10'
];
$request->validate([
'csv_file' => [
new Csv($csv_rules)
]
]);
Retrieve
You can access csv data by adding _data after attribute of csv file as follows.
$csv_data = $request->csv_file_data; // when attribute is `csv_file`
Messages
Attributes of error messages are like this.
The A1 field is required.
The C1 field is required.
The C2 must be at least 10 characters.
The C3 must be at least 10 characters.
The C4 field is required.
Contributor
Thank you for your contributions!
License
This package is licensed under the MIT License.
Copyright 2020 Sukohi Kuhoh
Related Packages
Powerful PHP database abstraction layer (DBAL) with many features for database s...
Laravel Serializable Closure provides an easy and secure way to serialize closur...
Cli error handling for console/command-line PHP applications.
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| 3.0.4 | ^5.7| | MIT | ||
| 3.0.3 | ^5.7| | MIT | ||
| 3.0.2 | ^5.7| | MIT | ||
| 3.0.1 | ^5.7| | MIT | ||
| 3.0.0 | ^5.7| | MIT | ||
| 2.0.0 | ~5.0 | LGPL | ||
| 1.0.2 | >=5.4.0 | 4.2.* | LGPL | |
| 1.0.1 | >=5.4.0 | 4.2.* | LGPL | |
| 1.0.0 | >=5.4.0 | 4.2.* |