new-admin-api/app/validate/api/user/RegisterValidates.php

54 lines
1.6 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\validate\api\user;
use think\Validate;
/**
* 注册验证
* Class RegisterValidates
* @package app\http\validates\api\user
*/
class RegisterValidates extends Validate
{
protected $regex = ['phone' => '/^1[3456789]\d{9}$/'];
protected $rule = [
'phone' => 'require|regex:phone',
'account' => 'require|regex:phone',
'captcha' => 'require|length:6',
'password' => 'require',
];
protected $message = [
'phone.require' => '手机号必须填写',
'phone.regex' => '手机号格式错误',
'account.require' => '手机号必须填写',
'account.regex' => '手机号格式错误',
'captcha.require' => '验证码必须填写',
'captcha.length' => '验证码长度不正确',
'password.require' => '密码必须填写',
];
public function sceneCode()
{
return $this->only(['phone']);
}
public function sceneRegister()
{
return $this->only(['account', 'captcha', 'password']);
}
}