<?php

namespace Kylin\Auth\Requests;

use Illuminate\Foundation\Http\FormRequest;

/**
 * 注册请求验证
 *
 * 验证用户注册时的输入参数。
 */
class RegisterRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'account' => ['required', 'string', 'min:2', 'max:50'],
            'password' => ['required', 'string', 'min:8', 'max:30'],
            'nickname' => ['nullable', 'string', 'max:30'],
        ];
    }

    public function messages(): array
    {
        return [
            'account.required' => '账号不能为空',
            'account.min' => '账号至少2个字符',
            'account.max' => '账号最多50个字符',
            'password.required' => '密码不能为空',
            'password.min' => '密码至少8位',
            'password.max' => '密码最多30位',
            'nickname.max' => '昵称最多30个字符',
        ];
    }
}
