mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-09-01 21:00:58 +00:00
28 lines
594 B
PHP
28 lines
594 B
PHP
<?php
|
|
|
|
namespace App\Platform\Storage\Rules;
|
|
|
|
use Closure;
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
use Illuminate\Support\Str;
|
|
|
|
/**
|
|
* Accepts only a path that names a zip archive.
|
|
*/
|
|
class PathToZip implements ValidationRule
|
|
{
|
|
public function __construct() {}
|
|
|
|
/**
|
|
* Reject any path that does not carry the zip extension.
|
|
*/
|
|
public function validate(string $attribute, mixed $value, Closure $fail): void
|
|
{
|
|
if (Str::endsWith($value, '.zip')) {
|
|
return;
|
|
}
|
|
|
|
$fail('The given value must be a path to a zip file.');
|
|
}
|
|
}
|