My Blog Posts

Laravel Zip Content Validator

Laravel Zip Content Validator

use Orkhanahmadov\ZipValidator\Rules\ZipContent;

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

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

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

You can also use a validation style "or" . The following is an example of "or" validation with the maximum size:

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

Finally, empty files False as a second argument Reject :

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

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

Share this article

Comments (0)