<?php

declare(strict_types=1);

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class UpdateProjectRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user() !== null;
    }

    public function rules(): array
    {
        // signal_type immutable: не валидируется в правилах, controller игнорирует поле
        return [
            'name' => ['sometimes', 'string', 'max:255'],
            'daily_limit_target' => ['sometimes', 'integer', 'min:1', 'max:10000'],
            'region_mask' => ['sometimes', 'integer', 'min:0'],
            'region_mode' => ['sometimes', Rule::in(['include', 'exclude'])],
            'delivery_days_mask' => ['sometimes', 'integer', 'min:1', 'max:127'],
            'sms_senders' => ['sometimes', 'array', 'min:1'],
            'sms_senders.*' => ['string', 'max:11'],
            'sms_keyword' => ['sometimes', 'nullable', 'string', 'min:1', 'max:50'],
        ];
    }
}
