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>
31 lines
935 B
PHP
31 lines
935 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Pterodactyl\Validation;
|
|
|
|
use Illuminate\Validation\Rule;
|
|
use Illuminate\Validation\Rules\NotIn;
|
|
use Pterodactyl\Models\Mount;
|
|
|
|
final class MountRules
|
|
{
|
|
/**
|
|
* Validation rules for the mount requests.
|
|
*
|
|
* @param Mount|null $ignore the mount being updated
|
|
* @return NormalizedValidationRules
|
|
*/
|
|
public static function rules(?Mount $ignore = null): array
|
|
{
|
|
return [
|
|
'name' => ['required', 'string', 'min:2', 'max:64', Rule::unique('mounts', 'name')->ignore($ignore)],
|
|
'description' => ['nullable', 'string', 'max:191'],
|
|
'source' => ['required', 'string', new NotIn(Mount::$invalidSourcePaths)],
|
|
'target' => ['required', 'string', new NotIn(Mount::$invalidTargetPaths)],
|
|
'read_only' => ['sometimes', 'boolean'],
|
|
'user_mountable' => ['sometimes', 'boolean'],
|
|
];
|
|
}
|
|
}
|