<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class StoreMailProfileRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user() && $this->user()->can('create', \App\Models\MailProfile::class);
    }

    public function rules(): array
    {
        return [
            'name' => ['required', 'string', 'max:190'],
            'host' => ['required', 'string', 'max:190'],
            'port' => ['required', 'integer', 'between:1,65535'],
            'encryption' => ['nullable', 'in:ssl,tls,starttls'],
            'username' => ['nullable', 'string', 'max:190'],
            'password' => ['required', 'string', 'max:512'],
            'from_address' => ['required', 'email', 'max:190'],
            'from_name' => ['nullable', 'string', 'max:190'],
            'reply_to_address' => ['nullable', 'email', 'max:190'],
            'reply_to_name' => ['nullable', 'string', 'max:190'],
            'priority' => ['nullable', 'integer', 'between:0,65535'],
            'max_daily_quota' => ['nullable', 'integer', 'min:0'],
            'signature' => ['nullable', 'array'],
            'signature.*' => ['nullable', 'string', 'max:1000'],
            'auto_mailer' => ['nullable', 'boolean'],
        ];
    }
}
