<?php
/**
 * Created by PhpStorm
 * User：林志杰
 * Email：598287049@qq.com
 * Motto：纵有疾风起，人生不言弃！
 * Time：2020/1/4 11:17
 */

namespace app\admin\validate;


use think\Validate;

class AdminUser extends Validate
{
    protected $rule = [
        'username' => 'require',
        'password' => 'require',
        'captcha' => 'require|checkCaptcha',
    ];

    protected $message = [
        'username' => '用户名必须',
        'password' => '密码必须',
        'captcha' => '验证码必须',
    ];

    protected function checkCaptcha($value, $rule, $data = [])
    {
        if (!captcha_check($value)) {
            // 验证码校验失败
            return '验证码不正确';
        }
        return true;
    }
}