User.php 877 字节
<?php

namespace app\admin\validate;

use think\Validate;

class User extends Validate
{
    /**
     * 验证规则
     */
    protected $rule = [
        'username' => 'require|unique:user',
        'password' => 'require|regex:\S{32}',
        'mobile' => 'require|regex:^1\d{10}$|unique:user',
    ];
    /**
     * 提示消息
     */
    protected $message = [
        'username.require' => '请填写用户名',
        'username.unique' => '用户名已存在',
        'password.require' => '请填写密码',
        'password.regex' => '密码格式错误',
        'mobile.require' => '请填写手机号',
        'mobile.regex' => '手机号格式错误',
        'mobile.unique' => '手机号已存在',
    ];
    /**
     * 验证场景
     */
    protected $scene = [
        'add'  => ['username','password','mobile'],
        'edit' => [],
    ];
    
}