Mobile.php
682 字节
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
/**
* 验证手机号
* Class Mobile
* @package App\Rules
* @author zbj
* @date 2023/4/19
*/
class Mobile implements Rule
{
/**
* Determine if the validation rule passes.
*
* @param string $attribute
* @param mixed $value
* @return bool
*/
public function passes($attribute, $value)
{
$cardReg = '/^1(3|4|5|7|8)\d{9}$/';
return preg_match($cardReg, $value);
}
/**
* Get the validation error message.
*
* @return string
*/
public function message()
{
return '手机号码格式不正确';
}
}