UserValidate.php 2.2 KB
<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2018 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 小夏 < 449134904@qq.com>
// +----------------------------------------------------------------------
namespace api\portal\validate;

use think\Validate;

class UserValidate extends Validate
{
    protected $rule = [
        'name' => ['require','length:2,4','chs'],
        'password' => ['require','length:6,16','alphaNum'],
        'tel' => ['regex'=>' /^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/','require'],
        'sure_password' => 'require',

        'city' => 'require',
        'company' => 'require',
        'store' => 'require',
        'quarters' => 'require',
    ];
    protected $message = [
        'name.require' => '姓名不能为空!',
        'name.length' => '姓名为2-4个汉字!',
        'name.chs' => '姓名只能是汉字!',
        'tel.require' => '手机号不能为空!',
        'tel.regex' => '手机号格式不正确!',
        'password.require' => '密码不能为空!',
        'password.length' => '密码长度为6-16位!',
        'password.alphaNum' => '密码格式不正确!',
        'sure_password.require' => '确认密码不能为空!',

        'city.require' => '城市不能为空!',
        'company.require' => '所属公司不能为空!',
        'store.require' => '门店不能为空!',
        'quarters.require' => '服务小区不能为空!',

    ];

    protected $scene = [
//        'add'  => ['name','tel','password','sure_password'],
//        'edit'  => ['tel','password','name','sure_password'],
        'user'  => ['tel','password','name','sure_password'],
        'intermediary'  => ['tel','password','name','sure_password','city','company','store','quarters'],
        'pass'  => ['password'],
    ];

}