BookStack/app/Exports/ZipExports/ZipFileReferenceRule.php

27 lines
541 B
PHP
Raw Normal View History

2024-10-30 21:13:41 +08:00
<?php
namespace BookStack\Exports\ZipExports;
use Closure;
use Illuminate\Contracts\Validation\ValidationRule;
use ZipArchive;
class ZipFileReferenceRule implements ValidationRule
{
public function __construct(
protected ZipValidationHelper $context,
) {
}
/**
* @inheritDoc
*/
public function validate(string $attribute, mixed $value, Closure $fail): void
{
if (!$this->context->zipReader->fileExists($value)) {
2024-10-30 21:13:41 +08:00
$fail('validation.zip_file')->translate();
}
}
}