<?php

namespace App\Http\Requests\Post;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rules\File;

class UpdatePostRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            'title' => ['required_without_all:content,image', 'string', 'max:255'],
            'content' => ['required_without_all:title,image', 'string', 'max:2048'],
        ];
    }

    public function messages()
    {
        return [
            'required_without_all' => 'At least one field is required.'
        ];
    }
}
