<?php

namespace App\Http\Requests\Auth;

use Illuminate\Foundation\Http\FormRequest;

class ChangePasswordRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'old_password' => 'required|string',
            'new_password' => 'required|string|min:6|max:20|different:old_password',
            'confirm_password' => 'required|string|same:new_password',
        ];
    }

    public function messages(): array
    {
        return [
            'old_password.required' => '请输入原密码',
            'new_password.required' => '请输入新密码',
            'new_password.min' => '新密码至少6位',
            'new_password.max' => '新密码最多20位',
            'new_password.different' => '新密码不能与原密码相同',
            'confirm_password.required' => '请确认新密码',
            'confirm_password.same' => '两次输入的密码不一致',
        ];
    }
}
