mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-11 01:24:46 +02:00
fd2cebe3cf
* chore: address deprecations to validation rules in Laravel 10 * style: fix StyleCI findings
42 lines
924 B
PHP
42 lines
924 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Rules\Wiki\Submission\Format;
|
|
|
|
use App\Rules\Wiki\Submission\SubmissionRule;
|
|
use Closure;
|
|
use Illuminate\Translation\PotentiallyTranslatedString;
|
|
|
|
/**
|
|
* Class TotalStreamsFormatRule.
|
|
*/
|
|
class TotalStreamsFormatRule extends SubmissionRule
|
|
{
|
|
/**
|
|
* Create new rule instance.
|
|
*
|
|
* @param int $expected
|
|
*/
|
|
public function __construct(protected readonly int $expected)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* 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
|
|
{
|
|
$streams = $this->streams();
|
|
|
|
if (count($streams) !== $this->expected) {
|
|
$fail(__('validation.submission.format_total_streams'));
|
|
}
|
|
}
|
|
}
|