| 12345678910111213141516171819202122232425 |
- <?php
- namespace App\Module\China\Validator;
- use UCore\Validator;
- class AlipayIdValidator extends Validator
- {
- public function validate(mixed $value, array $data): bool
- {
- // 正则表达式,用于匹配手机号或邮箱地址
- $regex = '/^(?:\d{11}|[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})$/';
- // 使用 preg_match 函数进行匹配
- if (preg_match($regex, $value)) {
- return true;
- } else {
- return false;
- }
- }
- }
|