Download the PHP package sukohi/csv-validator without Composer

On this page you can find all versions of the php package sukohi/csv-validator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package csv-validator

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


All versions of csv-validator with dependencies

PHP Build Version
Package Version
Requires illuminate/support Version ^5.7|^6.0|^7.0|^8.0
sukohi/fluent-csv Version ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package sukohi/csv-validator contains the following files

Loading the files please wait ....