New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

sukohi/csv-validator

A Laravel package that allows you to validate csv data.
51,003 8

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 advised

Not 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
Maintainer: Sukohi

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

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

670,032,257 9,703
laravel/framework

The Laravel Framework.

640,572,096 35,338
laravel/tinker

Powerful REPL for the Laravel framework.

546,909,908 7,440
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

465,816,364 607
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

431,187,642 4,660

Version History

Version Released PHP Laravel License
3.0.4 ^5.7|^6.0|^7.0|^8.0 MIT
3.0.3 ^5.7|^6.0|^7.0 MIT
3.0.2 ^5.7|^6.0 MIT
3.0.1 ^5.7|^6.0 MIT
3.0.0 ^5.7|^6.0 MIT