public class Check {
/**
* 名字验证
*
* @param name
* @return
* @throws DomainException
*/
public static boolean checkName(String name) throws DomainException {
// 姓名中可包含汉字和字母
Pattern pattern = Pattern.compile("([\\u4e00-\\u9fa5]+|[a-zA-Z]+)");
if (name.length() < 2 || name.length() > 4) {
throw new ParamFormatException("股东名字长度不符合要求,要求18或15位,提交了" + name.length());
} else {
Matcher matcher = pattern.matcher(name);
if (!matcher.matches()) {
throw new ParamFormatException("股东名字" + name + "格式不正确");// 包含了特殊字符
}
return true;// 不包含特殊字符
}
}
/**
* 身份证号码验证
*
* @param idCard
* @return
* @throws DomainException
*/
public static boolean checkIdCard(String idCard) throws DomainException {
// 定义判别用户身份证号的