<?php

namespace App\Http\Requests\Admin;

use App\Http\Requests\Admin\Concerns\AdminAccountFieldRules;
use App\Http\Requests\ApiFormRequest;

/**
 * 管理员登录请求。
 *
 * @see LoginController
 */
final class AdminLoginRequest extends ApiFormRequest
{
    use AdminAccountFieldRules;

    public function authorize(): bool
    {
        return true;
    }

    protected function prepareForValidation(): void
    {
        $this->normalizeAdminAccountFields();
    }

    /**
     * @return array<string, array<int, mixed>>
     */
    public function rules(): array
    {
        return [
            'account' => $this->adminLoginAccountRules(),
            'password' => $this->adminLoginPasswordRules(),
            'captcha_key' => ['required', 'string', 'uuid'],
            'captcha_code' => ['required', 'string', 'max:32'],
        ];
    }

}
