<?php

namespace Modules\User\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Modules\User\Rules\IdCardRule;

class CertificationRequest extends FormRequest
{

    public function rules(): array
    {
        return [
            'name'    => 'required|min:2|max:5',
            'id_card' => ['required', new IdCardRule(), 'unique:user_certifications'],
            // 'front_card' => 'required',
            // 'back_card'  => 'required',
        ];
    }

    public function messages(): array
    {
        return [
            'name.required'       => '认证用户姓名必须填写',
            'name.min'            => '认证用户姓名至少:min个字符',
            'name.max'            => '认证用户姓名最多:max个字符',
            'id_card.required'    => '身份证号必须填写',
            'id_card.unique'      => '身份证号已存在',
            'front_card.required' => '身份证正面图片必须上传',
            'back_card.required'  => '身份证背面图片必须上传',
        ];
    }

}