<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

/**
 * StoreKnowledgeBaseAnswerRequest
 * 
 * Validation for submitting a new answer to a knowledge base question.
 * Used in KnowledgeBaseAnswerController@store
 */
class StoreKnowledgeBaseAnswerRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return auth()->check() && auth()->user()->can('answer knowledge base questions');
    }

    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        return [
            'content' => 'required|string|min:20|max:10000',
        ];
    }

    /**
     * Get custom validation messages.
     */
    public function messages(): array
    {
        return [
            'content.required' => 'Answer content is required.',
            'content.min' => 'Answer must be at least 20 characters long.',
            'content.max' => 'Answer cannot exceed 10000 characters.',
        ];
    }
}
