<?php

namespace Kylin\Auth\Requests;

use Illuminate\Foundation\Http\FormRequest;

/**
 * 登录请求验证
 *
 * 验证用户登录时的输入参数，支持验证码校验。
 */
class LoginRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'account' => ['required', 'string', 'max:100'],
            'password' => ['required', 'string', 'min:8'],
            'captcha_key' => ['nullable', 'string'],
            'captcha_code' => ['nullable', 'string', 'size:6'],
        ];
    }

    public function messages(): array
    {
        return [
            'account.required' => '账号不能为空',
            'password.required' => '密码不能为空',
            'password.min' => '密码至少8位',
            'captcha_code.size' => '验证码为6位',
        ];
    }
}
