<?php

namespace App\Http\Requests\Api\V1;

use Illuminate\Foundation\Http\FormRequest;

class DirectUploadRequest 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 [
            'file' => [
                'required',
                'file',
                'max:10240', // 10MB max for direct upload
            ],
            'bucket_id' => ['required', 'exists:file_buckets,id'],
            'visibility' => ['sometimes', 'in:public,private,signed'],
        ];
    }

    /**
     * Get custom messages for validator errors.
     *
     * @return array<string, string>
     */
    public function messages(): array
    {
        return [
            'file.required' => 'A file is required.',
            'file.file' => 'The uploaded item must be a valid file.',
            'file.max' => 'Direct upload only supports files under 10MB. Use chunked upload for larger files.',
            'bucket_id.required' => 'A bucket must be specified.',
            'bucket_id.exists' => 'The specified bucket does not exist.',
            'visibility.in' => 'Visibility must be one of: public, private, signed.',
        ];
    }
}
