mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-26 16:54:30 +02:00
* chore: address deprecations to validation rules in Laravel 10 * style: fix StyleCI findings
42 lines
946 B
PHP
42 lines
946 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Rules\Storage;
|
|
|
|
use Closure;
|
|
use Illuminate\Contracts\Filesystem\Filesystem;
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
use Illuminate\Translation\PotentiallyTranslatedString;
|
|
|
|
/**
|
|
* Class StorageDirectoryExistsRule.
|
|
*/
|
|
readonly class StorageDirectoryExistsRule implements ValidationRule
|
|
{
|
|
/**
|
|
* Create a new rule instance.
|
|
*
|
|
* @param Filesystem $fs
|
|
* @return void
|
|
*/
|
|
public function __construct(protected Filesystem $fs)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Run the validation rule.
|
|
*
|
|
* @param string $attribute
|
|
* @param mixed $value
|
|
* @param Closure(string): PotentiallyTranslatedString $fail
|
|
* @return void
|
|
*/
|
|
public function validate(string $attribute, mixed $value, Closure $fail): void
|
|
{
|
|
if (! $this->fs->directoryExists($value)) {
|
|
$fail(__('validation.directory_exists'));
|
|
}
|
|
}
|
|
}
|