mirror of
https://github.com/pterodactyl/panel.git
synced 2026-11-30 11:25:52 -05:00
Co-authored-by: Anthony <anthony@infraly.co> Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
29 lines
788 B
PHP
29 lines
788 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Pterodactyl\Rules;
|
|
|
|
use Closure;
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
use Illuminate\Translation\PotentiallyTranslatedString;
|
|
use Pterodactyl\Services\Extensions\ExtensionSettingValueGuard;
|
|
use UnexpectedValueException;
|
|
|
|
final class ValidExtensionSettings implements ValidationRule
|
|
{
|
|
/**
|
|
* Run the validation rule.
|
|
*
|
|
* @param Closure(string, ?string=): PotentiallyTranslatedString $fail
|
|
*/
|
|
public function validate(string $attribute, mixed $value, Closure $fail): void
|
|
{
|
|
try {
|
|
ExtensionSettingValueGuard::assertValues($value);
|
|
} catch (UnexpectedValueException $unexpectedValueException) {
|
|
$fail($unexpectedValueException->getMessage());
|
|
}
|
|
}
|
|
}
|