<?php

namespace app\admin\validate;

use think\Validate;

class User extends Validate
{
    /**
     * 验证规则
     */
    protected $rule = [
        'username' => 'require|max:10',
        'nickname' => 'require|max:10',
        'mobile'   => ['require','regex:/^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$/'],
        'teach_phone'=> ['regex:/^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$/']
    ];

    /**
     * 字段描述
     */
    protected $field = [
        'username.require' => '用户名不能为空',
        'nickname.require' => '昵称不能为空',
        'mobile.require' => '手机号不能为空',
        'mobile.regex' => '手机号只能为11位,且只能为13,14,15,16,17,18,19开头',
        'teach_phone.regex' => '老师手机号只能为11位,且只能为13,14,15,16,17,18,19开头',
    ];
    /**
     * 提示消息
     */
    protected $message = [
    ];
    /**
     * 验证场景
     */
    protected $scene = [
        'add'  => [],
        'edit' => ['username','nickname','mobile','teach_phone'],
    ];

    public function __construct(array $rules = [], $message = [], $field = [])
    {
        $this->field = [
            'username' => __('Username'),
            'nickname' => __('Nickname'),
            'password' => __('Password'),
            'email'    => __('Email'),
            'mobile'   => __('Mobile')
        ];
        parent::__construct($rules, $message, $field);
    }

}