123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace App\Rules;
- use Illuminate\Contracts\Validation\Rule;
- /**
- * 检测邮件验证码
- *
- * @author 刘相欣
- *
- */
- class Phone implements Rule{
- /**
- * 判断是否通过验证规则
- *
- * @param string $attribute
- * @param mixed $value
- * @return bool
- */
- public function passes($attribute, $value)
- {
- // 解码
- $result = preg_match('/^1[3-9]\d{9}$/',$value);
- // 错误提示
- return $result ? true : false;
- }
- /**
- * 获取校验错误信息
- *
- * @return string
- */
- public function message()
- {
- return trans('validation.phone');
- }
- }
|