2026-10-05 18:10:18 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace Pterodactyl\Validation;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Validation\Rule;
|
|
|
|
|
use Pterodactyl\Models\Mount;
|
2026-10-07 22:24:12 +05:45
|
|
|
use Pterodactyl\Rules\NotInPathHierarchy;
|
2026-10-05 18:10:18 -04:00
|
|
|
|
|
|
|
|
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 [
|
2026-10-07 22:24:12 +05:45
|
|
|
'name' => [
|
|
|
|
|
'required',
|
|
|
|
|
'string',
|
|
|
|
|
'min:2',
|
|
|
|
|
'max:64',
|
|
|
|
|
Rule::unique('mounts', 'name')->ignore($ignore),
|
|
|
|
|
],
|
2026-10-05 18:10:18 -04:00
|
|
|
'description' => ['nullable', 'string', 'max:191'],
|
2026-10-07 22:24:12 +05:45
|
|
|
|
|
|
|
|
'source' => [
|
|
|
|
|
'required',
|
|
|
|
|
'string',
|
|
|
|
|
'starts_with:/',
|
|
|
|
|
new NotInPathHierarchy(Mount::$invalidSourcePaths),
|
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
'target' => [
|
|
|
|
|
'required',
|
|
|
|
|
'string',
|
|
|
|
|
'starts_with:/',
|
|
|
|
|
new NotInPathHierarchy(Mount::$invalidTargetPaths),
|
|
|
|
|
],
|
|
|
|
|
|
2026-10-05 18:10:18 -04:00
|
|
|
'read_only' => ['sometimes', 'boolean'],
|
|
|
|
|
'user_mountable' => ['sometimes', 'boolean'],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|