<?php

namespace App\Modules\Settings\Onboarding\Requests;

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

class SaveOnboardingLocaleRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user()?->can('onboarding.manage') ?? false;
    }

    public function rules(): array
    {
        return [
            'locale' => ['required', 'string', 'max:12', Rule::exists('languages', 'code')->where('is_active', true)],
        ];
    }
}
