IndexValidate.php 1.5 KB
<?php

namespace app\api\validate;

use think\Validate;

class IndexValidate extends Validate
{

    /**
     * 验证规则
     */
    protected $rule = [
        'service_type' => 'require|in:1,2',
        'cart_type'    => 'require|in:1,2',
        'nickname'     => 'require',
        'avatar'       => 'require',
        'realname'     => 'require',
        'mobile'       => 'require|regex:/^1\d{10}$/',
        'id_number'    => ['require', 'regex' => '^\d{18}$|^\d{17}(X|x)$'],
        'code'         => 'require',
        'id_images'    => 'require',
    ];

    /**
     * 提示消息
     */
    protected $message = [
        'service_type.require' => '请选择服务类型',
        'service_type.in'      => '服务类型参数错误',
        'cart_type.require'    => '请选择汽车类型',
        'nickname.require'     => '昵称不能为空',
        'avatar.require'       => '头像不能为空',
        'cart_type.in'         => '汽车类型参数错误',
        'realname.require'     => '请输入真实姓名',
        'mobile'               => '请输入正确的电话号',
        'id_number'            => '请输入正确的身份证号',
        'code'                 => '请输入验证码',
        'id_images'            => '请上传身份证图片',
    ];

    /**
     * 验证场景
     */
    protected $scene = [
        'select_goods' => ['service_type', 'cart_type'],
        'login'        => ['nickname', 'avatar'],
        'apply'        => ['realname', 'mobile', 'id_number', 'code', 'id_images'],
    ];

}