MemberValidate.php 1.4 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 app\portal\validate;

use think\Validate;

class MemberValidate extends Validate
{
    protected $rule = [
        'name' => 'require',
        'tel' => 'require|regex:/^[1][3,4,5,7,8][0-9]{9}$/',
        'card_num' => 'require|min:15',
    ];
    protected $message = [
        'name.require' => '姓名不为空!',
        'tel.require' => '手机号不能为空!',
        'tel.regex' => '手机号格式不正确!',
        'card_num.require' => '身份证号不为空!',
        'card_num.min' => '身份证号格式不正确!',

    ];

    protected $scene = [
        'isset'=>['tel.regex','card_num.min']
    ];

    // edit 验证场景定义
    public function sceneIsset()
    {
        return $this->only(['tel','card_num'])
            ->remove('tel', 'require')
            ->remove('card_num', 'require')
            ;
    }
}