mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-11-01 20:18:00 +01:00
26 lines
684 B
PHP
26 lines
684 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Rules\GraphQL\Argument;
|
|
|
|
use Closure;
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
use Illuminate\Support\Facades\Config;
|
|
use Illuminate\Translation\PotentiallyTranslatedString;
|
|
|
|
readonly class FirstArgumentRule implements ValidationRule
|
|
{
|
|
/**
|
|
* @param Closure(string): PotentiallyTranslatedString $fail
|
|
*/
|
|
public function validate(string $attribute, mixed $value, Closure $fail): void
|
|
{
|
|
$maxCount = Config::get('graphql.pagination_values.max_count');
|
|
|
|
if ($maxCount !== null && $value > $maxCount) {
|
|
$fail(__('validation.max.numeric', ['max' => $maxCount]));
|
|
}
|
|
}
|
|
}
|