This repository has been archived on 2020-11-09. You can view files and clone it, but cannot push or open issues or pull requests.
Files
pingan/app/Rules/Mobile.php
2020-08-06 16:37:53 +08:00

41 lines
664 B
PHP

<?php
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
class Mobile implements Rule
{
/**
* 确定验证规则是否通过。
*
* @param string $attribute
* @param mixed $value
* @return bool
*/
public function passes($attribute, $value)
{
if (strlen($value) != 11) {
return false;
}
if (!preg_match("/^1[3456789]{1}\d{9}$/", $value)) {
return false;
}
return true;
}
/**
* 获取验证错误消息。
*
* @return string
*/
public function message()
{
return '手机号格式有误';
}
}