<?php

namespace App\Http\Requests\Roles;

use App\Http\Requests\ApiFormRequest;
use Illuminate\Validation\Rule;

class RoleStoreRequest extends ApiFormRequest
{
    public function authorize(): bool
    {
        return auth()->check();
    }

    public function rules(): array
    {
        return [
            'name' => ['required', 'string', 'min:3', 'max:255', 'unique:roles,name'],
            'slug' => ['nullable', 'string', 'max:64', 'unique:roles,slug'],
            'description' => ['nullable', 'string', 'max:500'],
            'dashboard_route' => ['required', 'string', 'min:1', 'max:255', 'regex:/^[a-z0-9_\\/\\-]+$/'],
            'priority' => ['required', 'integer', 'min:0', 'max:100000'],
            'is_active' => ['required', Rule::in([0, 1, '0', '1', true, false])],
        ];
    }
}
