<?php

namespace App\Http\Requests\Files;

use App\Http\Requests\ApiFormRequest;

class FileNameRequest extends ApiFormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'name' => ['required', 'string', 'max:255', 'regex:/^[^\/\\\\]+$/'],
        ];
    }

    protected function prepareForValidation(): void
    {
        if ($this->route('name') !== null) {
            $this->merge(['name' => $this->route('name')]);
        }
    }
}
