minuteoflaravel/laravel-csv-validator

Adds CSV validator to your Laravel project

1.0.4 2022-05-20 13:52 UTC

This package is auto-updated.

Last update: 2024-04-22 19:46:14 UTC


README

This package adds a CSV validator to your Laravel project. This validator parses uploaded file using parsecsv/php-parsecsv library and validation is passed when there are no errors during parsing.

This package doesn't validate against a MIME type or file extension.

Installation

You can install package via composer:

composer require minuteoflaravel/laravel-csv-validator

Example

Check if a file has a CSV format:

$request->validate([
    'uploaded_file' => 'csv',
]);

Custom error messages

If you need to add your custom translatable error message then just add it as always to resources/lang/en/validation.php file:

  'csv' => 'The :attribute must be a CSV file.',

License

The MIT License (MIT). Please see License File for more information.