fixbug手机号校验
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package com.common.utils;
|
||||
|
||||
import com.ydd.framework.core.exception.ExceptionCodeTemplate;
|
||||
import com.ydd.framework.core.exception.ServiceException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* replace jar Validate
|
||||
*/
|
||||
public class VenueValidateUtils {
|
||||
public static boolean isMobile(String mobile) {
|
||||
if (StringUtils.isNotBlank(mobile)) {
|
||||
Pattern pattern = Pattern.compile("^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\\d{8}$");
|
||||
return pattern.matcher(mobile).matches();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static void assertMobile(String mobile) {
|
||||
if (!StringUtils.isBlank(mobile) && !isMobile(mobile)) {
|
||||
throw new ServiceException(ExceptionCodeTemplate.INVALID_MOBILE);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user