validate/Admin.php
<?php
namespace app\admin\validate;
use think\Validate;
/**
* Description of Validate
*
* @author Ivan
*/
class Admin extends Validate
{
protected $rule = [
'username' => 'require|min:3|unique:admin',
'password' => 'require|min:6',
];
protected $message = [
'username.require' => '用户名必须',
'username.min' => '用户名不少于3个字符长度',
'username.unique' => '用户名唯一',
'password.require' => '用户密码必须',
'password.min' => '密码长度必须大于6',
];
protected $scene = [
'add' => ['username','password'],
'edit' => ['username'=>'require|min:3','password'=>'min:6'],
];
}
unique后边必须跟上 :表名
网友评论