]> BookStack Code Mirror - bookstack/blob - app/Exports/ZipExports/ZipFileReferenceRule.php
ZIP Exports: Added ID checks and testing to validator
[bookstack] / app / Exports / ZipExports / ZipFileReferenceRule.php
1 <?php
2
3 namespace BookStack\Exports\ZipExports;
4
5 use Closure;
6 use Illuminate\Contracts\Validation\ValidationRule;
7
8 class ZipFileReferenceRule implements ValidationRule
9 {
10     public function __construct(
11         protected ZipValidationHelper $context,
12     ) {
13     }
14
15
16     /**
17      * @inheritDoc
18      */
19     public function validate(string $attribute, mixed $value, Closure $fail): void
20     {
21         if (!$this->context->zipReader->fileExists($value)) {
22             $fail('validation.zip_file')->translate();
23         }
24     }
25 }