mirror of
https://github.com/pterodactyl/panel.git
synced 2026-12-05 13:55:44 -05:00
32 lines
1.1 KiB
PHP
32 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Pterodactyl\Validation;
|
|
|
|
use Illuminate\Validation\Rule;
|
|
use Pterodactyl\Models\Server;
|
|
|
|
final class ServerRules
|
|
{
|
|
/**
|
|
* Validation rules for the requests that update a server's details and startup.
|
|
* Creating a server uses CreateServer::rules(), and its build UpdateServerBuild::rules().
|
|
*
|
|
* @param Server|null $ignore the server being updated
|
|
* @return NormalizedValidationRules
|
|
*/
|
|
public static function rules(?Server $ignore = null): array
|
|
{
|
|
return [
|
|
'external_id' => ['sometimes', 'nullable', 'string', 'between:1,191', Rule::unique('servers', 'external_id')->ignore($ignore)],
|
|
'owner_id' => ['required', 'integer', 'exists:users,id'],
|
|
'name' => ['required', 'string', 'min:1', 'max:191'],
|
|
'description' => ['string'],
|
|
'egg_id' => ['required', 'exists:eggs,id'],
|
|
'startup' => ['required', 'string'],
|
|
'image' => ['required', 'string', 'max:191', 'regex:/^~?[\w\.\/\-:@ ]*$/'],
|
|
];
|
|
}
|
|
}
|