Laravel Zip Content Validator

Laravel Zip Content Validator

Laravel Zip Content Validator by Orkhan Ahmadov is a custom validation rule for checking the contents of an uploaded ZIP file:

use Orkhanahmadov\ZipValidator\Rules\ZipContent;

public function rules()
    return [
        'file' => [
            new ZipContent('thumb.jpg', 'assets/logo.png')

In addition to checking the existence of file paths, you can also validate the maximum size of a file. The unit of the value is bytes: 100000 equals 100KB:

new ZipContent(['thumb.jpg' => 100000, 'logo.png']);

You can also use an “or” style of validation. Here’s an example of “or” validation in tandem with maximum size:

new ZipContent(['thumb.jpg|thumb.png' => 100000]);

Finally, you can reject empty files with false as a second argument:

new ZipContent(['thumb.jpg', 'style.css'], false);

You can learn more about this package, get full installation instructions, and view the source code on GitHub: laravel-zip-validator.

Filed in: News
Laravel News Partners

Laravel Jobs

PHP Developer - Full time w/ benefits, US Only
Northern Virginia or Remote (US Only)
Guidance Residential
Full Stack Developer
Laravel API Developer
Las Vegas, NV (Must work on-site)
V Shred
Laravel Developer (Vue, SQL Server)
World Trade Organization
Web Application Developer (Vue.js & Laravel)
Apero Creative Development


Join 31,000+ others and never miss out on new tips, tutorials, and more.