增加手机号正则验证

This commit is contained in:
xingyu 2022-08-11 11:32:38 +08:00
parent 5addfbbb94
commit e1b8ae09c9
2 changed files with 5 additions and 7 deletions

View File

@ -17,16 +17,15 @@ import java.util.regex.Pattern;
*/ */
public class ValidationUtils { public class ValidationUtils {
private static final Pattern PATTERN_MOBILE = Pattern.compile("^(?:(?:\\+|00)86)?1(?:(?:3[\\d])|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\\d])|(?:9[189]))\\d{8}$");
private static final Pattern PATTERN_URL = Pattern.compile("^(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]"); private static final Pattern PATTERN_URL = Pattern.compile("^(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]");
private static final Pattern PATTERN_XML_NCNAME = Pattern.compile("[a-zA-Z_][\\-_.0-9_a-zA-Z$]*"); private static final Pattern PATTERN_XML_NCNAME = Pattern.compile("[a-zA-Z_][\\-_.0-9_a-zA-Z$]*");
public static boolean isMobile(String mobile) { public static boolean isMobile(String mobile) {
if (StrUtil.length(mobile) != 11) { return StringUtils.hasText(mobile)
return false; && PATTERN_MOBILE.matcher(mobile).matches();
}
// TODO 芋艿后面完善手机校验
return true;
} }
public static boolean isURL(String url) { public static boolean isURL(String url) {

View File

@ -53,9 +53,8 @@ public class AlipayQrPayClientTest extends BaseMockitoUnitTest {
"lrsYhKkVK2OxwM3kFqjoBBY0CZoZCsSQ3LDH5WeZqPArlsS6xa2zqJBuuoKjMrdpELl3eXSjP8K54eDJCbeetCZNKWLL3DPahTPB7LZ" + "lrsYhKkVK2OxwM3kFqjoBBY0CZoZCsSQ3LDH5WeZqPArlsS6xa2zqJBuuoKjMrdpELl3eXSjP8K54eDJCbeetCZNKWLL3DPahTPB7LZ" +
"ikfYmslb0QUvCgGapD0xkS7eVq70NaL1G57MWABs4tbfWgxike4Daj3EfUrzIVspQxj7w8HEj9WozJPgL88kSJSits0pqD3n5r8HSuseQIDAQAB"); "ikfYmslb0QUvCgGapD0xkS7eVq70NaL1G57MWABs4tbfWgxike4Daj3EfUrzIVspQxj7w8HEj9WozJPgL88kSJSits0pqD3n5r8HSuseQIDAQAB");
// TODO @tina= 前后要有空格哈
@InjectMocks @InjectMocks
AlipayQrPayClient client=new AlipayQrPayClient(10L,config); AlipayQrPayClient client = new AlipayQrPayClient(10L,config);
@Mock @Mock
private DefaultAlipayClient defaultAlipayClient; private DefaultAlipayClient defaultAlipayClient;