<?php

namespace App\Http\Requests;

use Illuminate\Validation\Rule;

class StoreSpecDocument extends SpecDocumentRequest
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            'tenant_id' => [
                'required',
                'string',
                Rule::exists(config('tenancy.database.central_connection') . '.tenants', 'id'),
                Rule::unique(config('tenancy.database.central_connection') . '.spec_documents', 'tenant_id'),
            ],
            'title' => ['required', 'string', 'max:255'],
            'version' => ['sometimes', 'nullable', 'string', 'max:50'],
        ];
    }
}
